markW - Tuesday, November 27, 2007 2:25 AM:
I am having trouble getting the getPropertyItem API function to work. I hope someone may be able to point out what I am doing wrong. My goal is, given the name of a Relationship type, to find the source and related items for this relationship type. There might even be more elegant ways to do what I am trying to accomplish, but I woud still like to know if I am using the API function correctly.
Pretty simple:
If I do this:
IOM.Item itDis = Inn.newItem("relationshipType", "get");
itDis.setProperty("name", "mw_counter_To_kpi");
IOM.Item result = itDis.apply();
textBox1.Text = result.dom.InnerXml;
I get the AML for my desired Item type in the text box, no problem. Here are the key portions of the response:<Envelope xmlns:xsd="www.w3.org/.../XMLSchema">
<source_id keyed_name="mw_ctr_01" type="ItemType" name="mw_ctr_01">3AE49E0CE2BD4E108EBC459A94781B6C</source_id>
...
So, the related_id and source_id Item types are what I am looking for.
I try this:
IOM.
Item itDis = Inn.newItem("relationshipType", "get");itDis.setProperty(
"name", "mw_counter_To_kpi");IOM.
Item result = itDis.apply();IOM.
Item itemProp = result.getPropertyItem("source_id");textBox1.Text = itemProp.dom.InnerXml;
I get an error message. The API command is so straight forward I am not sure what else to try. Am I mis-interpreting something about the command or perhaps the Relationship Type item type?
Any help will be greatly appreciated.
Mark
snnicky - Tuesday, November 27, 2007 7:34 AM:
Please pay attention that there is no tag Item inside tag source_id. Thus getPropertyItem is not applicable.
If you try
IOM.Item itemProp = result.getPropertyItem("related_id");
textBox1.Text = itemProp.dom.InnerXml;
this should work.
Since you know ItemType id you may request the ItemType. For example:
string id = result.getProperty("source_id");
IOM.Item it = Inn.newItem("ItemType", "get");
it.setID(id);
it = it.apply();
Also I noticed that you specified incorrect type name. That should be RelationshipType and not relationshipType.