You are viewing limited content. For full access, please sign in.

Question

Question

On Modern Form Designer on Cloud, can I run JavaScript code when an Action Button is Clicked?

asked two days ago

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?

0 0

Replies

replied two days ago

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.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.