I have multiple BPF's for a entity. I have events registered onStageChange & onStageSelected of the BPF. These function are written on the onload block of the JS.
I can switch the BPF using the Switch Process ribbon button. When I switch the process then the onload block executes and sets the field value of a custom field but it is not saved . It gets reflected as unsaved changes. There is a custom function which sets the value of that custom field but it doesn't save the value. The value is only saved only after explicitly saving the form.
If I would explicitly save the form in the custom function it would again call the function which is registered on onSave event.
Any suggestions /approaches to overcome the issue of unsaved changes on BPF switch.
Thanks in advance!
Hi Shrivesh Tatte,
Please try these ways:
1. Still save the form in the custom function but you need to pass the saveOptions parameter in which you need to customize a save mode number(Please don't use the number in this list) to the formContext.data.save() function. Something like this:
//customize a SaveMode number
formContext.data.save({"saveMode":71});
Then in your onSave event, please add these lines to make your business not executed:
function onSave(executionContext){
var saveMode = executionContext.getEventArgs().getSaveMode();
if(saveMode == 71){
return;
}
//your business
...
}
This way would still trigger the onSave event.
2. Don't use formContext.data.save() in your custom function. Instead, use Web API to update your current record and invoke the formContext.data.refresh(false) function in the success callback function to refresh the data. This way wouldn't trigger the onSave event.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156