Workflow Process Get Change ItemType

Good day all.  I have a Method to dynamically assign a drafter to the activity.  Currently I have to specify the ItemType of the change I am using for this method to work, meaning I would have to recreate the Method for each different kind of change ItemType I want to use this on.  How can I pull the associated change ItemType from the Workflow Process or Workflow Process Activity that the method is running from to make this a more generic method?  The Method is written in C#.  Thank you for your help.

  • // Called OnActivate from the Work Request activity of sm_NDR. This will assign the drafter selected by the Drafting Lead.

    Innovator inn = this.getInnovator();
    string actId = this.getID();

    // Retrieve the workflow item
    Item wflItem = this.newItem("Workflow","get");
    Item wflProc = wflItem.createRelatedItem("Workflow Process","get");

    Item wflProcAct = wflProc.createRelationship("Workflow Process Activity","get");
    wflItem = wflItem.apply();
    if (wflItem.getItemCount() != 1 || wflItem.getProperty("source_id","").Length != 32 || wflItem.getPropertyAttribute("source_type","keyed_name","").Length < 1)
    return inn.newError("Error retrieving workflow: "+wflItem.getErrorDetail());

    //GET the Drafter from the NDR
    Item ecoParent = this.newItem("sm_NDR", "get");

    bool permissionWasSet = false;
    Aras.Server.Security.Identity transIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM");

    permissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(transIdentity);

    //GET the Identity from the User
    Item ecoDrafter = this.newItem("User","get");

    Item getAssignment = this.newItem("Activity Assignment", "get");
    getAssignment.setProperty("source_id", actId);
    getAssignment.setAttribute("select", "id");
    getAssignment = getAssignment.apply();

    // This deletes the Identities for the Activity if the Workflow had to be stepped backwards (i.e. rework the document)
    for (int i = 0; i < getAssignment.getItemCount(); i++)
    var assignmentId = getAssignment.getItemByIndex(i).getID();
    Item removeAssignment = this.newItem("Activity Assignment", "delete");
    removeAssignment.setAttribute("id", assignmentId);
    removeAssignment.setAttribute("doGetItem", "0");
    removeAssignment = removeAssignment.apply();
    return inn.newError("Error removing assignment: "+removeAssignment.getErrorDetail());

    // Add the Drafter to the Activity Assignment
    Item assignment = this.newItem("Activity Assignment", "");
    assignment.setProperty("source_id", this.getID());

    string drafter = ecoDrafter.getProperty("owned_by_id"); // Get Drafter Identity ID
    assignment.setProperty("related_id", drafter);
    assignment.setProperty("voting_weight", "100");
    Item result = assignment.apply();
    if (result.isError())
    return inn.newError("Workflow Assignment: Error adding assignment: " + result.getErrorDetail());


    if (permissionWasSet)
    return this;

  • Happy to see that there are also other users that offer rework possibilities in their Change Management processes. 

    Regarding your questions: The easiest way to get the top ItemType would be to use the 'labs_GetControlledItemCSharp' Method. With this Method you don´t have to go through all the Workflow and Assignment relationships by yourself and it´s highly reusable:

    Item controlledItem = this.newItem(this.getAttribute("type"), "labs_GetControlledItemCSharp");
    controlledItem = controlledItem.apply();
    string cmType = controlledItem.getAttribute("type");

    Of course the Method is also a good reference when you want to do the query by yourself. You should find it somewhere in the Aras Labs github website.

  • AngelaIp,

    Thank you again for your help.  This worked.  I added your lines into my code and changed the sm_NDR in line "Item ecoParent = this.newItem("sm_NDR", "get");" to cmType.