Create Work Order UI action button Script Help?

Irfan53
Mega Contributor

Hello,

After suggestion from community here, I extended OOTB create work order UI action on incident to create copy with button as checked mark, it was acceptable by client.

I was able to create work order as button UI action. Create a UI page which act a glide modal pop up window with Yes/NO. Yes created work order , No destroyed pop up.

After it was given for testing, QAT tester informed window should pop only when mandatory fields on incident are not empty. If it's empty and this UI a button click I should get Info message. If Mandatory is not empty then I should get pop up window. Pop is fine but not able to client side validation.

 

Here is script , I tried but not working. 

Click on - createWO()

 

function createWO() {

// This highlights all missing mandatory fields automatically
if (!g_form.checkMandatory()) {
g_form.addInfoMessage(
"Please fill all mandatory fields highlighted in red before creating the Work Order."
);
return; // stop execution
}

// Open confirmation modal only when form is valid
var dialog = new GlideModal("Incident_FSM_Confirmation_Dialog_Box");
dialog.setTitle("Create Work Order");
dialog.setSize(400, 300);
dialog.render();
}

 

It does not work but when I remove if it works.

 

@GlideFather  , @Dr Atul G- LNG , @Mohammed8 , @Joshua Chen MTL .

Can you please suggest what's going wrong.

 

Thanks in Advance

and Happy Holidays/ Christmas

1 REPLY 1

Mohammed8
Giga Sage

Hi @Irfan53 , 

I assume your rest of code works fine and only if block is not executing properly.

 

Mohammed8_0-1766512283924.png

 

I tried to check for the highlighted script code, i didn't get much official documentation on it, open console on form and check whether its throwing error or not

 

Meanwhile you can try this for client form validation:

 

 var arr = g_form.getMissingFields();

    if (arr.length > 0) {

        g_form.addErrorMessage(

            "Please fill all mandatory fields highlighted in red before creating the Work Order."

        );

        return; // stop execution

    }

 

Thanks and Regards,

Mohammed Zakir