Created
February 24, 2020 09:21
-
-
Save YMA-MDL/da6222d71bc149872491bbddcf8a7729 to your computer and use it in GitHub Desktop.
Get Controlled Item #aras #method #csharp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieve the workflow item(s) | |
Innovator inn = this.getInnovator(); | |
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"); | |
wflProcAct.setProperty("related_id",this.getID()); | |
wflItem = wflItem.apply(); | |
if (wflItem.getItemCount() < 1 || | |
wflItem.getItemByIndex(0).getProperty("source_id","").Length != 32 || | |
wflItem.getItemByIndex(0).getPropertyAttribute("source_type","keyed_name","").Length < 1) | |
{ | |
return inn.newError("Error retrieving workflow: " + wflItem.getErrorDetail()); | |
} | |
// Build a list of ids For the versions of the controlled item | |
StringBuilder idList = new StringBuilder(); | |
for (int i=0; i<wflItem.getItemCount(); i++) { | |
if (wflItem.getItemByIndex(i).getProperty("source_type","") != wflItem.getItemByIndex(0).getProperty("source_type","")) | |
{ | |
return inn.newError("Error: Workflow Process attached to items of different types"); | |
} | |
idList.Append("'" + wflItem.getItemByIndex(i).getProperty("source_id","") + "',"); | |
} | |
idList.Remove(idList.Length - 1, 1); | |
// Retrieve the current item controlled by the workflow | |
string contType = wflItem.getItemByIndex(0).getPropertyAttribute("source_type","keyed_name",""); | |
Item contItem = this.newItem(contType,"get"); | |
contItem.setProperty("is_current","1"); | |
contItem.setProperty("id",idList.ToString()); | |
contItem.setPropertyAttribute("id","condition","in"); | |
contItem = contItem.apply(); | |
if (contItem.getItemCount() != 1) return inn.newError("Error retrieving controlled item: " + contItem.getErrorDetail()); | |
return contItem; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment