The title kind of says it all...
I need to assign some values to variables once the Submit or Approve button is clicked on. How can I trap this event on the Modern designer and run some code?
The title kind of says it all...
I need to assign some values to variables once the Submit or Approve button is clicked on. How can I trap this event on the Modern designer and run some code?
This JavaScript will move the Action button result to a field in the form you can hide but save the value:
LFForm.onFormSubmission(async function (event) {
const actionValue = event?.data?.action?.value;
if (actionValue) {
LFForm.setFieldValues({ fieldId: 5 }, actionValue);
// Wait briefly to ensure the value is stored before submission
await new Promise(resolve => setTimeout(resolve, 100));
}
});
Change the field ID to the field ID in your form where you want to store the result. I tested and it will work on first submission and task action buttons.
Thank you so much for this really simple elegant solution. This was my third try at looking for a solution to changing variables based on submit button click. I go side treacked on trying to figure out the field number of the submit button. Never did find it. You solution is what I needed. Thanks so much !!