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

Sending variables from Workflow to Attributes

Sending variables from Workflow to Attributes

I have a questions regarding setting documents attributes based on variables in a workflow. I have been able to pull the attributes of a document and set them as variables in a workflow, but was wondering if there is a way to do it in the opposite way? I am trying to alleviate some steps that my users would have to do by incorporating updates in a User's Task, as opposed to them having to go in and editing the documents attributes and then completing the task as a placeholder/reminder. I was wondering if I would be able to use a similar code as to what I used to set variables from attributes to accomplish this, but I don't know any of the code classes to accomplish this. Below is a copy of the code I used to pull information into the Workflow, I am hoping it's just a simple variation on this, since I understand what's going on in this code. Any help you guys can provide would be very beneficial.

wt.fc.QueryResult qr = null;
wt.doc.WTDocument RCIDFDoc=((wt.doc.WTDocument)primaryBusinessObject);
ext.generic.util.IBAUtil objHelper = new
ext.generic.util.IBAUtil(RCIDFDoc);
ApplicationNum=objHelper.getIBAValue("ApplicationNum");
BusinessCategory=objHelper.getIBAValue("BusinessCategory");
EstimatedNetSales=objHelper.getIBAValue("EstimatedNetSales");
FGNum=objHelper.getIBAValue("FGNum");

3 REPLIES 3

Re: Sending variables from Workflow to Attributes

We recently did this for a customer, where we set the document and Change Notice attributes from workflow variables. So I know it is definitely possible. Unfortunately, I don't directly have access to this code.

One item to consider is that, every time you set the object attributes, Windchill creates an iteration to track the change. So you may not want to do this often if you are worried about creating lot of iterations.

Highlighted

Re: Sending variables from Workflow to Attributes

Create a class UpdateDocument .

In workflow Expression Robot call the class .
It will work

The oly thing is the Document will get updated by user wcadmin .

Re: Sending variables from Workflow to Attributes

I don't know if your ibautil handles checkout/checkin/save/etc, so I'll give you an example of setting a modeled WTDocument attribute.

In the "Complete" transition of your activity, add a call like:

try {

//you're not currently using self but it's a good idea to pass it. You'll never know when you're going to need it.

primaryBusinessObject = mypackage.UpdaterThingamajig.update(primaryBusinessObject,self,description);

} catch(Exception e) {

//up to you

}

//method for UpdaterThingamajig - public static WTObject update(WTObject primaryBusinessObject, ObjectReference self, String description) throws Exception {

Transaction trx = null;
try {
trx = new Transaction();
trx.start();
WTDocument doc = (WTDocument)primaryBusinessObject;
Folder checkoutFolder = WorkInProgressHelper.service.getCheckoutFolder();
CheckoutLink col = WorkInProgressHelper.service.checkout(document,checkoutFolder,"Updating something...");
document = (WTDocument)col.getWorkingCopy();
document.setDescription(description);
document = (WTDocument)PersistenceHelper.manager.save(document);
document = (WTDocument)WorkInProgressHelper.service.checkin(document,"Updated something...");
trx.commit();
return document;
} catch(Exception e) {
if(trx != null) {
trx.rollback();
}
throw e;
}

}

Something like this should work

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group