Good day all. Has an anyone set a method to add the current workflow activity name to a change field? We reference the changes more by the workflow activity than we do by the change state. Thanks for your help with this.
Good day all. Has an anyone set a method to add the current workflow activity name to a change field? We reference the changes more by the workflow activity than we do by the change state. Thanks for your help with this.
I guess I should have come back to this and post the C# method I use. I have this assigned to the Activities of the Workflow Template with an On Activate event.
// Called OnActivate from activities in a change workflow. Gets the Activity name and assigns it to the sm_workflow_activity field // Works as of 30 June 2023 NDH Innovator inn = this.getInnovator(); string actId = this.getID(); // GET current Activity ID // Added for Method identification associated to error message 27 September 2022 NDH string methodName = "\r\n Method: sm_Get_Activity_Name"; // GET workflow item Item wflItem = this.newItem("Workflow","get"); wflItem.setAttribute("select","source_id,source_type"); Item wflProc = wflItem.createRelatedItem("Workflow Process","get"); wflProc.setAttribute("select","name"); Item wflProcAct = wflProc.createRelationship("Workflow Process Activity","get"); wflProcAct.setAttribute("select","related_id,name"); wflProcAct.setProperty("related_id",this.getID()); wflItem = wflItem.apply(); // VERIFY that the Workflow has been retrieved 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() + methodName); } // GET ItemType of the change using the Method - labs_GetControlledItemCSharp Item controlledItem = this.newItem(this.getAttribute("type"), "labs_GetControlledItemCSharp"); controlledItem.setID(this.getID()); controlledItem = controlledItem.apply(); Item wflActivity = this.newItem("Activity","get"); wflActivity.setAttribute("select","name"); wflActivity.setID(wflProcAct.getProperty("related_id")); wflActivity = wflActivity.apply(); string cmType = controlledItem.getAttribute("type"); string activityName = ""; switch(wflActivity.getProperty("name")) { case "Close Change": case "Close ECR": case "End": activityName="Closed - Completed"; break; case "Cancel Change": case "Cancelled": activityName="Closed - Cancelled"; break; default: activityName=wflActivity.getProperty("name"); break; } bool permissionWasSet = false; Aras.Server.Security.Identity transIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM"); try { // permissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(transIdentity); Aras.Server.Security.Identity admin = null; bool permsWasSet = false; admin = Aras.Server.Security.Identity.GetByName("Aras PLM"); permsWasSet = Aras.Server.Security.Permissions.GrantIdentity(admin); // SET the Workflow Activity field from the change var ecoParent = this.newItem(cmType, "edit"); ecoParent.setID(wflItem.getProperty("source_id")); ecoParent.setProperty("sm_workflow_activity",activityName); ecoParent = ecoParent.apply(); } finally { if (permissionWasSet) { Aras.Server.Security.Permissions.RevokeIdentity(transIdentity); } } return this; // return inn.newError("Test: " + activityName);
Copyright © 2024 Aras. All rights reserved.