Auto Workflow Assignment - Defined Identity in ECR Item

I have reviewed the 'Auto Workflow Assignment' lab.

I wish to model the following scenario:

1. Add a mandatory 'ECR Coordinator' property to the ECR ItemType and ECR Form. The ECR creator selects the User that will coordinate the processing of the ECR. (Done)

2. Create a new ECR 'Workflow Map' that has the assignment of 'ECR Coordinator' at certain Activities. The 'ECR Coordinator' is an Identity with no members. (Done)

3. Create a new ECR, and the following occurs. (to be Done)

3.1 The OnActivate method determines the 'Get Controlled Item'.

3.2 The relationships are expanded from the 'Controlled Item' to find all the activities that have the 'ECR Coordinator' identity assigned.

Workflow Process -> Workflow Process Activity -> Activity -> Activity Assignment -> Identity

3.3 For each 'Activity Assignment' relationship  that has the 'ECR Coordinator' identity assigned either

(a) Change the related_id from 'ECR Coordinator' to the user assigned as the ECR Coordinator from the ECR item


(b) Create a new 'Activity Assignment' relationship between the Activity and the 'ECR Coordinator' user. Then delete the existing 'Activity Assignment' relationship that has the related_id of 'ECR Coordinator'.

4. The Workflow Process continues, with the 'ECR Coordinator' being given tasks, and email notifications.

  • Hi rif6894,

    If you copy the following into your onActivate method, it should do what you need (tested for Innovator 12.0, older versions might not support all of the C# functionality in the code). Note my "ECR coordinator" property on the ECR has name "ecr_coordinator" and the ID of my "ECR coordinator" identity is '1999BBE8AC784D1C8E99A74FC6C9E537'.

        EcrCoordinatorHandler ecrHandler = new EcrCoordinatorHandler(this);
        return ecrHandler.OnActivate();

    public class EcrCoordinatorHandler
       private readonly Innovator _innovator;
       private readonly Item _thisItem;

       public EcrCoordinatorHandler(Item item)
         _thisItem = item;
         _innovator = item.getInnovator();

       public Item OnActivate()
         Item ecrInstance = GetEcrInstance();
         string ecrCoordinatorId = ecrInstance.getProperty("ecr_coordinator");
         return string.IsNullOrWhiteSpace(ecrCoordinatorId)
           ? _innovator.newError("No ecr_coordinator found.")
           : SetEcrCoordinatorAssignments(ecrCoordinatorId);

       private Item SetEcrCoordinatorAssignments(string ecrCoordinatorId)
         Item activityAssignment = _innovator.newItem("Activity Assignment", "edit");

         string whereClause =
           $"innovator.[Activity_Assignment].source_id='{_thisItem.getID()}' AND innovator.[Activity_Assignment].related_id='1999BBE8AC784D1C8E99A74FC6C9E537'";

         activityAssignment.setAttribute("where", whereClause);
         activityAssignment.setProperty("related_id", ecrCoordinatorId);
         return activityAssignment.apply();

       private Item GetEcrInstance()
         Item workflow = _innovator.newItem("Workflow", "get");
         workflow.setAttribute("select", "source_type, source_id");
         Item workflowProcess = _innovator.newItem("Workflow Process", "get");
         Item workflowProcessActivity = _innovator.newItem("Workflow Process Activity", "get");
         workflowProcessActivity.setProperty("related_id", _thisItem.getID());
         workflow = workflow.apply();

         Item controlledItem = _innovator.newItem();
         controlledItem.setAttribute("typeId", workflow.getProperty("source_type"));
         return controlledItem.apply();



    Tested it for a setup similar to yours and it worked as intended. No idea if this is all kosher, but since no one else has answered in three days, I thought I might as well.
    The code is in such a shape because I simply adapted something I already had in my own "ArasHelpersAndHandlers" library (I had a use case similar to yours and only had to change a bit of the code). You can, of course, change that on your end so that you only have the method, without any class or anything like that.



Reply Children
No Data