Vardhan - Tuesday, January 22, 2013 5:48 AM:
Hi all,
While creating a document, If I select document's Type as 'Software' then the document should be related automatically to a part whose 'Type' is Software on saving the document.
How to do this?
I' m thinking that the code should be something like this:
Dim innovator As Innovator = Me.getInnovator()
Dim classification As String = Me.getProperty("classification")
If classification = "Software" Then
Dim part As Item =innovator.newItem("Part","get")
part.setAttribute("select","classification")
part.setProperty("classification","software")
part.setPropertyCondition("classification","like")
Dim result As Item = part.Apply()
''' Code to relate this document to the part'''
End If
But no luck in finding the code to relate the document. Please help me.
Thank you .
Vardh
vasant - Tuesday, January 22, 2013 6:14 AM:
Hi Vardh,
Find below sample code for relating the Document with Part:
''' Start Code to relate this document to the part'''
Dim cnt As Integer=result.getItemCount() - 1
For i = 0 To cnt
Dim partDocument As Item =innovator.newItem("Part Document","add")
partDocument.setProperty("source_id",result.getItemByIndex(i).getProperty("id"))
partDocument.setProperty("related_id",itemId)
Dim partDocumentRes As Item=partDocument.apply()
Next i
''' End Code to relate this document to the part'''
Thanks-Vasant
Vardhan - Tuesday, January 22, 2013 6:56 AM:
Hi Vasant,
Thanks for your help. What is the 'itemId' in the above code? It is not declared any where. Is that the Id of document?
Vardh.
vasant - Tuesday, January 22, 2013 7:29 AM:
Hi,
Yes, itemId is the id of the document saved.
Dim itemId As String=Me.getProperty("id")
Thanks-Vasant