Community Tip - You can change your system assigned username to something more personal in your community settings. X
I am creating a workflow with one activity. If that activity is completed, then the value of the IBA (Material_Type) must be changed from whatever the user has entered to value defined here (Copper).
I tried the following codes but still did not get the result. please help me to solve this.
1.
com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(primaryBusinessObject, null,java.util.Locale.getDefault(), new com.ptc.core.meta.common.UpdateOperationIdentifier());
obj.load("Material_Type");
obj.set("Material_Type", "Copper");
obj.apply();
2.
object = (wt.fc.WTObject)
com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(object,null,java.util.Locale.getDefault(),new com.ptc.core.meta.common.UpdateOperationIdentifier());
obj.load("Material_Type");
obj.set("Material_Type", "Copper");
obj.apply();
wt.fc.PersistenceHelper.manager.modify(object);
3.
wt.fc.QueryResult qr = wt.part.WTPart(primaryBusinessObject);
while (qr.hasMoreElements())
{
wt.fc.Persistable my_persistable = (wt.fc.Persistable)qr.nextElement();
my_persistable = wt.vc.wip.WorkInProgressHelper.service.checkout( (wt.vc.wip.Workable) my_persistable, wt.vc.wip.WorkInProgressHelper.service.getCheckoutFolder(),"").getWorkingCopy();
com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(my_persistable,null,java.util.Locale.US,new com.ptc.core.meta.common.UpdateOperationIdentifier());
obj.load("Material_Type");
obj.set("Material_Type", "Copper");
obj.apply();
wt.fc.PersistenceHelper.manager.modify(my_persistable);
wt.vc.wip.WorkInProgressHelper.service.checkin((wt.vc.wip.Workable) my_persistable,"");
}
Solved! Go to Solution.
You can add below code in Activity's complete transition. to update the attribute value
wt.part.WTPart part = ( wt.part.WTPart) primaryBusinessObject;
wt.folder.Folder checkoutFolder = wt.vc.wip.WorkInProgressHelper.service.getCheckoutFolder();
wt.vc.wip.CheckoutLink checkout = wt.vc.wip.WorkInProgressHelper.service.checkout(part, checkoutFolder,
null);
wt.fc.Persistable my_persistable = checkout.getWorkingCopy();
com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject(
my_persistable, null, java.util.Locale.ENGLISH, null);
obj.load("Material_Type");
obj.set("Material_Type", "Copper");
obj.apply();
wt.fc.PersistenceHelper.manager.save(my_persistable);
wt.vc.wip.WorkInProgressHelper.service.checkin(part, "Updated By Workflow");
let me know if it works
Thanks
Shreyas
You can add below code in Activity's complete transition. to update the attribute value
wt.part.WTPart part = ( wt.part.WTPart) primaryBusinessObject;
wt.folder.Folder checkoutFolder = wt.vc.wip.WorkInProgressHelper.service.getCheckoutFolder();
wt.vc.wip.CheckoutLink checkout = wt.vc.wip.WorkInProgressHelper.service.checkout(part, checkoutFolder,
null);
wt.fc.Persistable my_persistable = checkout.getWorkingCopy();
com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject(
my_persistable, null, java.util.Locale.ENGLISH, null);
obj.load("Material_Type");
obj.set("Material_Type", "Copper");
obj.apply();
wt.fc.PersistenceHelper.manager.save(my_persistable);
wt.vc.wip.WorkInProgressHelper.service.checkin(part, "Updated By Workflow");
let me know if it works
Thanks
Shreyas
Hey Shreyas,
It worked. Thanks a lot.
Even after trying various permutations and combinations in the codes, i couldn't get it.
I just request you to explain me what did you do? (If possible line by line). I am a fresher and relatively new to Windchill. This would help me to hone my skills.
Regards,
Prasad