Miscellaneous Ramblings on Hacking

January 28, 2009

RNOWOrganization – how to add a parent?

Filed under: .Net, RightNow — Zack Bethem @ 4:04 am

I’m still working with hacking my way through C#. The latest stumbling block is adding an organization with an associated parent organization. The end result would look like the following within RightNow:
Hierarchy

To date, I have the following code using the RNOW Data Connection API

// set parent org
if (Convert.ToString(row[38]) != "")
{
int z = getXrefId(Convert.ToString(row[38]), tblXrefIds);
if (z != 0)
{
RNOWOrganization parentOrg = new RNOWOrganization(z);
List parentOrgs = new List();
parentOrgs.Add(parentOrg.ID);
myOrg.Parent = parentOrgs;
}
else
{
//log error
}
}

The current question? The code syntax 'myOrg.Parent = parentOrgs;' doesn’t work. Instead, I get the error:
Cannot implicitly convert type ‘System.Collections.Generic.List<int>’ to ‘System.Collections.Generic.List<int?>’

Seems same to me.

Argh!!! Why can it just be a single Integer representing the ID of the organization. A list to set a single parent? What for? Make it simple stupid. The head scratching continues.

Update

Turns out C# provides a way to define a nullable list of collections. This is defined by the ‘?’ notation. So, parentOrgs in the code snippet above had to be defined by:

List<int?> parentOrgs = new List<int?>();
Defining the hierarchy is still not working 100%, but this hurdle is hopped over.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: