This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

APPLICATION - PRODUCT ENGINEERING - Workflow Assignment

Ron - Thursday, October 4, 2007 10:36 AM:

These workflows are very interesting to setup. I am very close to finalizing our ECR workflow, I have the form setup so that the CS1 agent assigns users to preform the tech review and up to four users for a CRB review. A new issue has been raised with respect to a loop back in the workflow where a CRB member may request additional information from the Tech reviewer. The method I am using to assign the Tech reviewers is assigning the same people twice at this point. The code I am using is as follows


' Workflow Assignment Example

' Demonstrates dynamic workflow assignment based on properties of the controlled item


' Get the controlled item

Dim innovator As Innovator = Me.newInnovator()

Dim controlledItem As Item = Me.newItem(Me.GetType(),"Get Controlled Item")

controlledItem.setID(Me.getID())

controlledItem = controlledItem.apply()

If controlledItem.isError() Then

Return controlledItem

End If


' Build an array of the reviewers

Dim reviewers As New ArrayList()

Dim i As Integer

For i = 0 To 3

If controlledItem.getProperty("tech_reviewer"&(i+1),"") <> "" Then reviewers.Add(controlledItem.getProperty("tech_reviewer"&(i+1),""))

Next


' Add an assignment for each reviewer

Dim assignment As Item = Me.newItem("Activity Assignment","")

assignment.setAction("add")

assignment.setAttribute("leaveLocked","0")

assignment.setProperty("source_id",Me.getID())

For i = 0 To reviewers.Count - 1

assignment.setProperty("related_id",reviewers.Item(i))

assignment.setProperty("voting_weight",100 reviewers.Count + 1)

Dim res As Item = assignment.apply()

If res.isError() Then

Return innovator.newError("Workflow Assignment: Error adding assignment: " & res.getErrorDetail())

End If

Next


' Change the Activity text (just so a change is visible in the InBasket)

Dim activity = Me.newItem(Me.GetType(),"edit")

activity.setID(Me.getID())

activity.setProperty("message",CStr(reviewers.Count)&" Assignments Added")

activity = activity.apply()

If activity.isError() Then

Return innovator.newError("Error editing activity: " & activity.getErrorDetail())

End If


I have tried various spins on if statements, but I keep coming up wrong.


Looking for help.



SamsAn - Monday, October 8, 2007 4:35 AM:

Hi.

The code seems correct (the assignments are not added twice). 

Are you sure that the method is called once during your manipulations?

SamsAn.



htran - Monday, March 10, 2008 12:18 PM:

Hi Samsan,

(I am very new to Aras Innovator, please forgive me for my questions).

 

' Workflow Assignment Example
' Demonstrates dynamic workflow assignment based on properties of the controlled item
 
' Get the controlled item
Dim innovator As Innovator = Me.newInnovator()
Dim controlledItem As Item = Me.newItem(Me.GetType(),"Get Controlled Item")
controlledItem.setID(Me.getID())
controlledItem = controlledItem.apply()
If controlledItem.isError() Then
 Return controlledItem
End If
 
' Build an array of the reviewers
Dim reviewers As New ArrayList()
Dim i As Integer
For i = 0 To 1
 If controlledItem.getProperty("assignee"&(i+1),"") <> "" Then reviewers.Add(controlledItem.getProperty("assignee"&(i+1),""))
Next
 
' Add an assignment for each reviewer
Dim assignment As Item = Me.newItem("Activity Assignment","")
assignment.setAction("add")
assignment.setAttribute("leaveLocked","0")
assignment.setProperty("source_id",Me.getID())
For i = 0 To reviewers.Count - 1
 assignment.setProperty("related_id",reviewers.Item(i))
 assignment.setProperty("voting_weight",100 reviewers.Count + 1)
 Dim res As Item = assignment.apply()
 If res.isError() Then
  Return innovator.newError("Workflow Assignment: Error adding assignment: " & res.getErrorDetail())
 End If
Next
 
' Change the Activity text (just so a change is visible in the InBasket)
Dim activity = Me.newItem(Me.GetType(),"edit")
activity.setID(Me.getID())
activity.setProperty("message",CStr(reviewers.Count)&" Assignments Added")
activity = activity.apply()
If activity.isError() Then
 Return innovator.newError("Error editing activity: " & activity.getErrorDetail())
End If
 
___________________

I agreed that the above codes work correctly.  But Ron needs to revise where the Technical Review get returned for Investigate. This is where the Reviewer name is set to more than one time (number of returns +1) with the same assignee name for each Investigate stage.

I think the statement below kept add 1 row to the Name, each time.  Is there a way we can use the "update" if the name exists or just don't "add"  ?

assignment.setAction("add")
 
Thanks a lot in advance.
Hong


SamsAn - Monday, March 10, 2008 12:40 PM:

Hi.

Please, note a row is added after

  assignment.apply()

code portion (it sends the request to Innovator Server that adds/updates the row).

The modified code below will not add assignments to the same activity twice (just will update the existing assignment).

' Add an assignment for each reviewer
Dim assignment As Item = Me.newItem("Activity Assignment","")
assignment.setAction("merge")
assignment.setAttribute("leaveLocked","0")
assignment.setProperty("source_id",Me.getID())
For i = 0 To reviewers.Count - 1
 assignment.setAttribute("where", "[Activity_Assignment].source_id='"+Me.getID()+"' AND [Activity_Assignment].related_id='"+reviewers.Item(i)+"'")
 assignment.setProperty("related_id",reviewers.Item(i))
 assignment.setProperty("voting_weight",100 reviewers.Count + 1)
 Dim res As Item = assignment.apply()
 If res.isError() Then
  Return innovator.newError("Workflow Assignment: Error adding assignment: " & res.getErrorDetail())
 End If
Next


htran - Tuesday, March 11, 2008 8:40 AM:

Great. the code works perfectly. Thanks very much.

Ht