One of the requirements we get that in a active workflow process, if a record is not in certain user's assignment, then it cannot be edited. Only assigned user can edit that record. We have implemented this requirement using automation script on Purchase Requisitions Application.
Object Launch Point : PR
Script : Jython
Object Event Condition:
(select count (ownerid) from wfassignment where ownertable='PR' and assignstatus='ACTIVE'
AND ownerid in (select prid from pr where prnum=:prnum))>0
and
(select count(ownerid) from wfassignment where ownertable='PR' and assignstatus='ACTIVE'
and assigncode in (:&USERNAME&) and ownerid in (select prid from pr where prnum=:prnum))=0
Events: Save, Add, Update, Before Save
Create Error Message:
Create error message in database configuration, errorgroup = 'PR' and errorkey = 'PR-ASSIGN'
Source Code:
errorgroup = 'PR'
errorkey = 'PR-ASSIGN'
Object Launch Point : PR
Script : Jython
Object Event Condition:
(select count (ownerid) from wfassignment where ownertable='PR' and assignstatus='ACTIVE'
AND ownerid in (select prid from pr where prnum=:prnum))>0
and
(select count(ownerid) from wfassignment where ownertable='PR' and assignstatus='ACTIVE'
and assigncode in (:&USERNAME&) and ownerid in (select prid from pr where prnum=:prnum))=0
Events: Save, Add, Update, Before Save
Create Error Message:
Create error message in database configuration, errorgroup = 'PR' and errorkey = 'PR-ASSIGN'
Source Code:
errorgroup = 'PR'
errorkey = 'PR-ASSIGN'
Dear Umar,
ReplyDeleteMaybe you can share how to trigger workflow (Route an assignment) from JSON API ?
You can trigger a workflow using the below script. Create a launch point with the name of the workflow you want to trigger. You can set this is to trigger on the Save > On Add launch type.
ReplyDeletefrom psdi.server import MXServer
MXServer.getMXServer().lookup("WORKFLOW").initiateWorkflow(launchPoint,mbo);