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 - Affected Items

gwilliams - Tuesday, November 13, 2007 12:18 PM:

Files are vaulted, Documents are created & ECN is created But the affected items list is to long to add one at a time through the ECN itself.

Can someone help me add affected items?

 

iomDoc.setProperty("owned_by_id", "30B991F927274FA3829655F50C99472E")

Dim str As String = iomDoc.getID   ' this is nothing

Dim EDdocRes As IOM.Item = iomDoc.apply()

Dim relItm As IOM.Item = inn.newItem("ECN Affected Item", "add")

Dim affItm As IOM.Item = inn.newItem("Affected Item", "add")

affItm.setProperty("affected_id", str)

relItm.setRelatedItem(affItm)

iomECN.addRelationship(relItm)

Next

SamsAn - Thursday, November 15, 2007 3:28 AM:

Hi.

The affected item list may be added in the one query using the parent ECN in a way like below:

Dim iomECN As Item = inn.newItem("ECN", "add")
Dim i As Integer
For i = 0 To affectedItemsList.Count - 1

  Dim relItm As IOM.Item = inn.newItem("ECN Affected Item", "add")

  Dim affItm As IOM.Item = inn.newItem("Affected Item", "add")

  affItm.setProperty("affected_id", str)

  relItm.setRelatedItem(affItm)

  iomECN.addRelationship(relItm)

Next i
iomECN.apply()


Hope it helps,

SamsAn. 



gwilliams - Monday, November 19, 2007 9:54 AM:

This is exactly what I am doing except I have iomECN in Edit mode. 

You must have over-looked this line.

Dim str As String = iomDoc.getID   ' this is nothing

I can't get the id of the iomDoc with this function or through the property itself.

I can see the id in the xml of iomDoc.

Gary



SamsAn - Monday, November 19, 2007 10:09 AM:

I don't know how iomDoc is generated, but i guess it is an instance of IOM Item class.

If you see id in the xml of iomDoc, then you may extract id directly from the XmlDocument like

  str = iomDoc.dom.selectSingleNode("xpath_to_the_element").getAttribute("id")

Another my guess - iomDoc contains a collection of items. Then id may be extracted like

  str = iomDoc.getItemByIndex(some_index_may_be_zero_for_example).getID()

SamsAn.



gwilliams - Monday, November 19, 2007 11:06 AM:

iomDoc is is a single item in edit mode.

I can set the properties and apply them.

The following lines return empty strings:

'Dim str As String = iomDoc.getID()

'Dim str As String = iomDoc.getItemByIndex(0).getID()

I can see the id in the xml.

Trying it this way it says -  'getAttribute' is not a member of 'System.Xml.XmlNode'.

Dim str As String = iomDoc.dom.SelectSingleNode("xpath_to_the_element").getAttribute("id")

imports are:

Imports

Aras

Imports

System.IO

Imports

System.web

Imports

System.Windows.Forms

 



SamsAn - Monday, November 19, 2007 11:17 AM:

Please, provide the code line used by you to see the id in the xml.

Do you get xml using the code like

    Dim xml As String = iomDoc.node.OuterXml

Or  

    Dim xml As String = iomDoc.dom.OuterXml


 SamsAn.



gwilliams - Monday, November 19, 2007 11:27 AM:

There is no code it is just a break point/ watch.

SamsAn - Monday, November 19, 2007 11:37 AM:

ok.

Did you add iomDoc to Watch and view its OuterXml, or just highlight iomDoc variable during debugging?

(anyway finally the xml may be recieved using the additional code line pointed by me in the prev comment).



gwilliams - Monday, November 19, 2007 11:44 AM:

Just highlight iomDoc variable during debugging.

If I had the xpath this might work.

Dim

str = iomDoc.dom.SelectSingleNode("xpath_to_the_element").Item("id")

Gary



SamsAn - Monday, November 19, 2007 11:50 AM:

Try to use this code

  Dim str As String = CType(iomDoc.dom.SelectSingleNode("//Item"), XmlElement).getAttribute("id")

gwilliams - Monday, November 19, 2007 12:06 PM:

This also returns an empty string.

Dim

str As String = CType(iomDoc.dom.SelectSingleNode("//Item"), Xml.XmlElement).GetAttribute("id")

Gary



SamsAn - Monday, November 19, 2007 12:16 PM:

Very strange... In which xml portion did you see id value? The latest my guess is <id> element. Thus this code line should help. Please, confirm.

Dim str As String = CType(iomDoc.dom.SelectSingleNode("//Item/id"), Xml.XmlElement).InnerText