How to get the value of relationship item type using the return value of fetchRelationships

オフライン

hi,All

'my code

'This is the code I tried to write in VB

Me.fetchRelationships("File")
Dim file as Item = Me.getRelationships("File")

Dim t_file_id as string
If file.getItemCount()>0
   Dim fileCnt as Integer=file.getItemCount()

   For x=0 To fileCnt-1
      t_file_id = file.getItemByIndex(x).getProperty("related_id")
      file1= file.getItemsByXPath("Relationships/Item[@id='"+t_file_id+" ']")
      file1.getProperty("doc_name")   ' return Not a single item
   Next

End If

'file 

'The value obtained is shown below

How do I get the doc_name value?

If somebody knows and can help I would really appreciate that.

Thank you.

  • I assume your current code returns the relationship itself instead of the related item.

    Maybe you can use getPropertyItem() or getRelatedItem():

    --> t_file_id = file.getItemByIndex(x).getPropertyItem("related_id").getProperty("doc_name");

  • オフライン in reply to AngelaIp

    Hi Angelalp,

       It works, thanks a lot for your help!
       I also tried another way to write it and the result is the same.

    'my code

    'This is the code I write in VB

    Me.fetchRelationships("File")
    Dim file as Item = Me.getRelationships("File")

    Dim t_file_id as string
    If file.getItemCount()>0
       Dim fileCnt as Integer=file.getItemCount()
       Dim docName as String

       For x=0 To fileCnt-1

    '      docName = file.getItemByIndex(x).getPropertyItem("related_id").getProperty("doc_name")
          file1 = file.getItemByIndex(x).getRelatedItem()
          docName = file1.getProperty("doc_name")
       Next

    End If