Forum Discussion
jamar
8 years agoIdeator III
Cheers mtk166, but this didn't appear to work. Got it working now though by setting as "On Close", and comparing the user identity of the active assignment with that of the logged in user and filtering by path. Had to also set an override path on the workflow though. Code below if anyone wants it. Works (for me) if there is multiple assignments, or just one, regardless if the assignment is a group identity or not.
Dim MyInn as Innovator = Me.getInnovator()
Dim CtrlItem As Item = MyInn.newItem("Activity", "TRL_Get_Controlled_Item")
CtrlItem.setID(Me.getID())
CtrlItem = CtrlItem.apply()
Dim ActivityAsgn As Item = MyInn.newItem("Activity Assignment", "get")
ActivityAsgn .setAttribute("select", "")
ActivityAsgn .setProperty("source_id", Me.getID())
ActivityAsgn = ActivityAsgn .apply()
Dim CurrActAs As Item = Nothing
Dim wfcomments as string = ""
Dim q as string = ""
Dim userID As String = MyInn.getUserAliases()
For I As Integer = 0 To (ActivityAsgn .getItemCount() - 1)
CurrActAs = ActivityAsgn .getItemByIndex(I)
wfcomments = CurrActAs.getProperty("comments")
q = ActivityAsgn .getItemByIndex(I).getRelatedItem().getProperty("id")
Dim myItemCM As Item = Me.newItem("Identity", "get")
myItemCM.setAttribute("select", "id")
myItemCM.setID(q)
Dim relationshipCM As Item = Me.newItem("Member", "get")
relationshipCM.setAttribute("select", "related_id")
Dim relatedItemCM As Item = Me.newItem("Identity", "get")
relatedItemCM.setAttribute("select", "id, keyed_name")
relationshipCM.setRelatedItem(relatedItemCM)
myItemCM.addRelationship(relationshipCM)
Dim resultsCM As Item = myItemCM.apply()
' Test for an error.
If resultsCM.isError() Then
Return MyInn.newError("Error: " + resultsCM.getErrorDetail())
End If
' Get a handle to the Member Items.
Dim memberItemsCM As Item = resultsCM.getRelationships("Member")
Dim countCM As Integer = memberItemsCM.getItemCount()
Dim iCM As Integer
Dim CMID_List As String = ""
' Iterate over the Member Items
For iCM = 0 To countCM - 1
' Get a handle to the relationship Item by index.
Dim memberItemCM As Item = memberItemsCM.getItemByIndex(iCM)
Dim IdentityID_method1CM As String = memberItemCM.getRelatedItem().getID()
CMID_List = CMID_List + "<br>" + IdentityID_method1CM
Next
Dim pathtotake as string = CurrActAs.getProperty("path")
If pathtotake = "Approve" Then Return Me
If CMID_List = "" Then ' not a group identity
If q = userID Then
If wfcomments = "" Then
Return MyInn.newError("Please fill in the comments section as to why you are voting to " + pathtotake)
Else
'Return MyInn.newError("wf comments: " + wfcomments)
Exit For
End If
Else
Continue For
End If
ElseIf CMID_List.Contains(userID)
If wfcomments = "" Then
Return MyInn.newError("Please fill in the comments section as to why you are voting to " + pathtotake)
Else
'Return MyInn.newError("wf comments: " + wfcomments)
Exit For
End If
End If
Next I
Return Me