meenu - Monday, March 4, 2013 6:45 AM:
Hi,
I have two Item types, IT1 & IT2 . IT2 is related to IT1. On IT2 I created one field to display the name of IT1 to which it is related. I' m using the following code to set the value to that field.
Dim innov As Innovator = Me.getInnovator()
Dim id As String = Me.getProperty("id")
Dim name As String = Me.getProperty("name")
Dim Item_2 As Item = innov.newItem("IT2","edit")
Item_2.setAttribute("where","[IT2].id in (select related_id from [RELATIONSHIP] where source_id = '"+id+"')")
Dim result As Item = Item_2.Apply()
Dim count As Integer = result.getItemCount() - 1
Dim i As Integer
For i = 0 To cnt
Dim itemtype_2 As Item = result.getItemByIndex(i)
Dim vendors As String = result.getItemByIndex(i).getProperty("src_name")
itemtype_2.setProperty("src_name",name)
Next i
Return Me
src_name is the property name of IT2.
I' m using this method on IT1 with OnBeforeAdd and OnBeforeUpdate . But this code is not working.
Is it the correct way of doing. Please help me
Thank You, M.K
Boro - Monday, March 4, 2013 11:30 PM:
Hello,
Please see the following code. I added setAction("edit") and apply() method on your code.
----
Dim innov As Innovator = Me.getInnovator()
Dim id As String = Me.getProperty("id")
Dim name As String = Me.getProperty("name")
Dim Item_2 As Item = innov.newItem("IT2","get")
Item_2.setAttribute("where","[IT2].id in (select related_id from [RELATIONSHIP] where source_id = '"+id+"')")
Dim result As Item = Item_2.Apply()
Dim count As Integer = result.getItemCount() - 1
Dim i As Integer
For i = 0 To cnt
Dim itemtype_2 As Item = result.getItemByIndex(i)
Dim vendors As String = result.getItemByIndex(i).getProperty("src_name")
itemtype_2.setProperty("src_name",name)
itemtype_2.setAction("edit")
itemtype_2.apply()
Next i
Return Me
-----
Thanks