Custom Code - submit form function

Hi YeeFlow,

On form action, we have to use “Submit Form” step to submit the form, image below:

image

Now my question is, can I use Custom code (Execute Script) alone to submit the form? if yes, any code example?

Thank you!

What I mean is that you can add a “Submit Form” action after the custom code action

1 Like

Hi @Jason thank you for your quick reply.

I just found out why my custom code not running in sequence. (run “Execute Script” and “Submit Form” at the same time)

Since I have some dialog require user to click before submit.

I need to make the show dialog function become async function like belows:

const common = context.modules[MODULE_COMMON];
const { AkModal } = common;
//...
async function showDialog(contentMsg) {
            return await new Promise((resolve, reject) => {
                AkModal.confirm({
                    title: "Alert",
                    content: contentMsg,
                    onOk: () => {
                        let obj = {};
                        resolve(true);
                    },
                    onCancel: () => {
                        let obj = {};
                        resolve(false);
                    }
                });
              });
        }

And call this function with await.

await showDialog("msg1");

Thank you so much for your time and assistance in solving this problem.

  1. You can use the Confirm dialog and the execution condition of the Submit Form is the value of the Confirm dialog.

  2. The execution conditions of the “ Submit Form” are defined by yourself. (alert)

execute(context: CodeInContext, fieldsValues: any) { 
   const common = context.modules[MODULE_COMMON];
       const { AkModal } = common; 
       AkModal.confirm({
           title: "Alert",
           content: "1213131231",
           onOk: () => {
               let obj = {};
               context.setFieldValue("alert",false);  
           },
           onCancel: () => {
               let obj = {};
               context.setFieldValue("alert",true);  
               console.log("false")
           }
       }); 
  }

1 Like