cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

Gather an attribute from a workflow task (Such as Completed By, Completed Date, & Comments) and write it to a document attribute

jbailey
17-Peridot

Gather an attribute from a workflow task (Such as Completed By, Completed Date, & Comments) and write it to a document attribute

Hello all,


First post on here... I am looking for guidance on how to gather attributes from a workflow task (such as task completer, when they completed it, and comments) and drive those comments to an attribute on the affected objects. Example... Promotion request for a document. Document is promoted, approvers complete their approval task. I want to be able to put those attributes back into the document before the set state robot runs on the promotion request.


I figure I will have to have some sort of expression robot, but what else? Anyone else done this sort of thing?



Jim Bailey
Systems Analyst
NASA GRC / Vantage Partners LLC

7 REPLIES 7
sauls
1-Newbie
(To:jbailey)



In Reply to James Bailey:



Hello all,


First post on here... I am looking for guidance on how to gather attributes from a workflow task (such as task completer, when they completed it, and comments) and drive those comments to an attribute on the affected objects. Example... Promotion request for a document. Document is promoted, approvers complete their approval task. I want to be able to put those attributes back into the document before the set state robot runs on the promotion request.


I figure I will have to have some sort of expression robot, but what else? Anyone else done this sort of thing?



Jim Bailey
Systems Analyst
NASA GRC / Vantage Partners LLC




The simplest way to do that is by editing directly the relevant objects.


If you seek for an automated way to transmit a value from the assignment task dialog window to the affected/resulting objects, it is more complex task, since windchill requires that any attribute being modified for an object must do a check-out and check-in. If you automate this process, you should also update the list of the affected/resulting objects to reflect the relevant iteration that includes the modified attributes.


If this is ok for you then the steps to do that are:


create a workflow variable attached to the task


in the approve transition, include the java code that identify the relevant object to update, check-out, update the value of the atribute from the contents of the workflow variable, check-in and update the affected/resulting list of objects accordingly.



An alternative mid-term approach can be to set the attribute that stores the comments in the ECN object itself, it can be updated without the check-out check-in process, without generating a new iteration, and if you want it to be reflected in the affected/resulting, you can use an alias type attribute, which is not persisted in Database, it is dynamically gathered during display, that points to the relevant ECN object.

Hi,


Regards,





//check other WorkflowHelper.service.getWorkItems() methods to get only required activities



while(workItems.hasMo...){


WorkItem workItem = (WorkItem) workItems.nextElement();


WfAssignedActivity wfAssgAct = (WfAssignedActivity) workItem.getSource().getObject();


String activityName = wfAssgAct.getName();


if (<user activity=" name=">.equalsIgnoreCase(activityName)) {


Timestamp compAt = wfAssgAct.getEndTime();


String compBy = workItem.getCompletedBy();



//<type> = workItem.;


}



}



//set attribute to WTDoc


//Checkout doc


//set attribute to doc


//CheckIn doc

Here is the code, which writes WF process variables wfApproverName and wfApproveDate (calculated elsewhere) into IBAs APPROVED_BY and APPROVED_ON, defined on WTDocument, without checkout/checkin.

Code iterates through all promotion objects (if more than one) and writes (same) data to all of them.

Works for EPM Documents too. Very useful in my opinion.

wt.maturity.PromotionNotice PBO_PN = ((wt.maturity.PromotionNotice) primaryBusinessObject);

wt.fc.QueryResult queryresult = wt.maturity.MaturityHelper.service.getPromotionTargets(PBO_PN, true);

while (queryresult.hasMoreElements())

{

    wt.fc.WTObject tempobj = (wt.fc.WTObject) queryresult.nextElement();

    if (tempobj instanceof wt.doc.WTDocument)

    {

        wt.doc.WTDocument obj = (wt.doc.WTDocument) tempobj ;

        wt.iba.value.service.LoadValue.establishCurrentIBAHolder(obj);

        //Save to IBA APPROVED_BY

        java.util.Hashtable cmdLine = new java.util.Hashtable();

        java.util.Vector returnObjs = new java.util.Vector();

        java.util.Hashtable nv = new java.util.Hashtable();

        nv.put("definition","APPROVED_BY");

        nv.put("value1", wfApproverName);

        wt.iba.value.service.LoadValue.createOrUpdateIBAValue(nv,cmdLine,returnObjs);

       

        //Save to IBA APPROVED_ON

        java.util.Hashtable cmdLine1 = new java.util.Hashtable();

        java.util.Vector returnObjs1 = new java.util.Vector();

        java.util.Hashtable nv1 = new java.util.Hashtable();

        nv1.put("definition","APPROVED_ON");

        nv1.put("value1", wfApproveDate);

        wt.iba.value.service.LoadValue.createOrUpdateIBAValue(nv1,cmdLine1,returnObjs1);

        //Save all IBAs to WTDoc

        wt.iba.value.service.LoadValue.saveCurrentIBAHolder();

    }

}

I put this code in an expression robot and get 3 syntax check errors

3-30-2016 2-29-14 PM.png

RoyCrerar
14-Alexandrite
(To:TomazJeras)

Hi, I'm very interested in what you posted here. Can you help me to understand where i would apply this code? I attempted something similar to create an alias attribute that I was then able to reuse but this seems to be more what I am looking for. Any help would be welcome.

If you are on 11.0 M030 or above we support copying routing choices, signatures and comments to the new Workflow Signatures table.  There is also the ability to have this copied from the PBO - say a Change or Promotion to the objects be released/promoted.

 

You need to update your workflow tasks with the following:

 

Two Activity Variables define behavior(Boolean)

windchillReview=true

windchillPropagate=true

 

Of course you also need to show the Workflow Records table on the data you want to see.

 

Note - there has been a gap on copying this to CAD Documents.  That is being worked on for the next Windchill release.

RoyCrerar
14-Alexandrite
(To:JeffZemsky)

Thanks for you input on this. I'm interested in getting this information stamped on my documents to show that the items have been formally approved is that something that I can do easily?

Top Tags