Upstream Relationships for a specific Item (velocity)

Options
Alex Wilson
Alex Wilson Member Posts: 2
edited November 2021 in
Hi all,

I am looking to collect a certain upstream item type, but can't seem to configure the function properly.

I have been using the below for Downstream Items and that works perfectly:
 #foreach($h1 in $documentSource.getRelationshipsForDocumentAndType($InputRef.getId(),186,true))
## additional code here
#end


Comments

  • Alessandro Valli
    Alessandro Valli Member, Data Exchange, Jama Connect Interchange™ (JCI) Posts: 784
    edited November 2021
    Options
    Hello Alex,
    I normally use
    • $documentSource.getDownstreamDocumentIds()
    • $documentSource.getUpstreamDocumentIds()
    or also
    • $documentSource.getRelationshipBetweenDocuments()
    No issues so far. Maybe you can get the list and then check for the item type ...

    Best,
    Alessandro
    Systems Engineer
    SICK AG
  • Alex Wilson
    Alex Wilson Member Posts: 2
    edited November 2021
    Options

    Hi Alessandro, Do you mean something like the following?

    #macro ($Function $InputRef $ListofDocs)
         #foreach($upstreamDoc in $documentSource.getUpstreamDocumentIds($InputRef.getId()))
              #if($186 == $documentSource.getDocumentTypeIdFromDocId(upstreamDoc .id)
                   #SuppressReturn($ListofDocs.add($upstreamDoc.getToDocument()))

    #end
    #end
    #end

    where:
    #macro(SuppressReturn $command) #set($temp = $command) #end

  • Alessandro Valli
    Alessandro Valli Member, Data Exchange, Jama Connect Interchange™ (JCI) Posts: 784
    edited November 2021
    Options
    Hi Alex,
    sorry for answering late, but now!
    getUpstreamDocumentIds is returning an ID -> upstreamDoc.id won't work.
    Just check the documentation -> Jama Software - Velocity engine
    Best,
    Alessandro
    Alessandro
    Systems Engineer
    SICK AG