BPM, Workflow, and Case

 View Only

 how do we save changes to business data in a process instance?

venkatesh sudhandhiran's profile image
venkatesh sudhandhiran posted Wed June 11, 2025 08:05 AM

Hello,

We are trying to save changes to the business data within a process instance. I have attached a screenshot of the business data that we are trying to change.

I am using the following Javascript snippet in order to accomplish this change

var processInstance =tw.system.findProcessInstanceByID(tw.local.letterProcessId);

if (processInstance !== null) {
        var LetterBO = processInstance.businessData.get("LetterObject");
        if (LetterBO !=null){
        processInstance.businessData.put("LetterObject.letterStatus", "Ferdig");
        processInstance.businessData.put("LetterObject.f22WaitingReplyLetter", false);
        processInstance.businessData.put("LetterObject.timeoutDate", null);          
        }

But the changes to the LetterObject are not being saved. What am I missing? Is there any explicit JS statement to save the changes to the businessData?

Best Regards,

Venkatesh

Grant Taylor's profile image
Grant Taylor

I would recommend using shared business objects for this scenario.  It appears that you are looking up a process instance outside of the process implementation.  Marking a business object as shared is the mechanism for sharing between processes, but it is also used for other external access scenarios.  In my sample, I marked my business object as shared:

I then have a Service Flow that is called by an external client.  A script in this Service Flow has code like this to read and update the values of the business object, which are seen by the original process:

tw.local.customerVar = new tw.object.Customer(tw.local.sharedBOKey);
tw.local.customerVar.firstName = "Some new name";
tw.local.customerVar.save();

The shared business object is created in the original code with code like this in a script activity of the process, which is where you also get the key to look up the shared business object from the external client:
tw.local.customerVar = new tw.object.Customer();
tw.local.sharedBOKey = tw.local.customerVar.metadata("key");

I hope this helps,

Grant.