This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Get Property Item

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">

- <Body>
- <Result>
- <Item type="RelationshipType" typeId="471932C33B604C3099070F4106EE5024" id="64DD7748A42443B992C23541844C919A" page="1" pagemax="1" itemmax="1">
  <core>0</core>
  <classification>/*</classification>
  <related_option>2</related_option>
  <related_notnull>1</related_notnull>
- <related_id keyed_name="mw_kpi_01" type="ItemType" name="ItemType">
- <Item type="ItemType" typeId="450906E86E304F55A34B3C0D65C097EA" id="0A728D290C5245B0BC951D9F00ED5D30" page="1" pagemax="1"
...

<source_id keyed_name="mw_ctr_01" type="ItemType" name="mw_ctr_01">3AE49E0CE2BD4E108EBC459A94781B6C</source_id>

...

  </Result>
  </Body>
  </Envelope>

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.