how to save into a variable and start a process at the same time?

I have a feature where the user clicks a link to run a process in the background and perform some actions. What I want to do is to display a message to the user while the PM is running so they know that something is going on. However, I found out that you can't do any other saves until the onSuccess is run. I want to run the following code.

a!dynamicLink(
showWhen: not(ri!inProgress),
value: true,
saveInto: {
a!save(ri!showMessage, true),
a!startProcess(
processModel: cons!WM_PM_SYNC_HOLDS_DATA,
processParameters: {
siteAcronym: ri!siteAcronym,
siteId: ri!siteId,
writeType: ri!writeType,
user: loggedInUser(),
lastSyncDate: ri!lastSyncDate
},
onSuccess: {
a!save(
ri!processInstance,
fv!processInfo.pp.id
)
},
onError: a!save(ri!error, "error")
),
}
),

In the code above, a!save(ri!showMessage, true) is not executed until the onSuccess() in the starProcess() is run even though it's outside of the startProcess. I've tried chaining the process and without any chaining and that save always waits for the PM on success or onError(). Is there a way to get around this? I know there is other ways like using a process report which is what I'm doing, I just want to know if this scenario is possible.

  Discussion posts and replies are publicly visible

Parents
  • I believe what is occurring here is that your form will not refresh until all of the saveInto's are complete, including the a!startProcess.  That would mean, unfortunately, you might not be able to achieve this exact scenario of having your interface re-evaluate in between a!save's.  How long roughly is this synch running?

    Without chaining, the onSuccess and onError (when applicable) should be executing as soon as the process starts (does so in my tests), thus will not give you access to any updated PV values that change down stream however, but you will have pp!id available.  With chaining, these evaluate after chaining is completed (however in my tests, it is maxing at around 50 chains even though we have our chaining limit increased to 100 via custom.properties...)

    One thought is to have your main process call a sub process asynchronously which does the synch, but you would lose access to some details then and you would need to auto refresh a variable that checks completion, or have a manual Refresh button available for the user.  And of course the shortest a!refreshVariable() setting is 30 seconds currently (..hoping we get access to shorter intervals in the future).

    Another thought is to combine some refreshing with a confirmMessage within a button containing these saves/synching, something like "Synch will begin now...form will update in 30 seconds...yadda yadda".

    Neither are as good for UX as your initial idea here, but just throwing some thoughts out there..

Reply
  • I believe what is occurring here is that your form will not refresh until all of the saveInto's are complete, including the a!startProcess.  That would mean, unfortunately, you might not be able to achieve this exact scenario of having your interface re-evaluate in between a!save's.  How long roughly is this synch running?

    Without chaining, the onSuccess and onError (when applicable) should be executing as soon as the process starts (does so in my tests), thus will not give you access to any updated PV values that change down stream however, but you will have pp!id available.  With chaining, these evaluate after chaining is completed (however in my tests, it is maxing at around 50 chains even though we have our chaining limit increased to 100 via custom.properties...)

    One thought is to have your main process call a sub process asynchronously which does the synch, but you would lose access to some details then and you would need to auto refresh a variable that checks completion, or have a manual Refresh button available for the user.  And of course the shortest a!refreshVariable() setting is 30 seconds currently (..hoping we get access to shorter intervals in the future).

    Another thought is to combine some refreshing with a confirmMessage within a button containing these saves/synching, something like "Synch will begin now...form will update in 30 seconds...yadda yadda".

    Neither are as good for UX as your initial idea here, but just throwing some thoughts out there..

Children
No Data