VB,how to Update the parent property in the onafterupdate event
I have an item type and a relationship I want to calculate the sum of one of the columns of the relationship when the user presses the save button and update it to the parent item. If I put the method in the onafterupdate of the parent item, it will do an infinite loop If I put the method in the onafterupdate of the relationship, when I update the value of more than one relationship, it will prompt me that 「Aras.Server.Core.ItemIsNotLockedException」... 'this is my parent onafterupdate method code Dim inn As Innovator = Me.getInnovator() Dim score_1 as Integer = Me.getProperty("score_1") ' parentItem.自評分數 Me.fetchRelationships("Performance_SelfScore") Dim rs as Item = Me.getRelationships("Performance_SelfScore") 'get relationship Dim rsCnt as Integer = rs.getItemCount() If rsCnt < 1 Then Else Dim i,self_score,sum_self_score as Integer sum_self_score=0 For i=0 to rs.getItemCount() -1 self_score = rs.getItemByIndex(i).getProperty("self_score") sum_self_score = sum_self_score + self_score Next Dim score1 as String = Me.getProperty("score_1") Dim successor_job_cname as String = Me.getProperty("successor_job_cname") Me.setProperty("score_1",sum_self_score) ' '↓↓The following code is what I use to update the parent property 'The first way 'Dim Self_Eval As Item = Me.newItem("Performance_Self_Evaluation","edit") ' Self_Eval.setAttribute("where","id ='" + Me.getID() + "'") ' Self_Eval.setProperty("score_1",sum_self_score) ' Self_Eval.setProperty("successor_job_cname","approve_mg")'day_auth.getProperty("approve_mg")) ' Self_Eval = Self_Eval.apply() 'If Self_Eval.isError() Then ' Return inn.newError ("Performance_VB_test:Error Update Performance_Self_Evaluation " & Self_Eval.getErrorDetail()) 'End If ' 'Second method 'Dim Self_Eval As Item = inn.getItemById("Performance_Self_Evaluation", Me.getID()) ' Self_Eval.setAction("edit") ' Self_Eval=Self_Eval.apply() ' Self_Eval.setProperty("score_1",sum_self_score) ' 'The third way 'Me.setAction("edit") 'Me.setProperty("score_1",sum_self_score) 'Dim resultItem As Item = Me.apply() 'Me.setAction("") '↑↑ score1 = Me.getProperty("score_1") successor_job_cname = Me.getProperty("successor_job_cname") End If Can anyone give me any idea?4.7KViews0likes5CommentsHow 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.4KViews0likes2Comments