UI action on client script not triggering

Khalnayak
Tera Guru

Hi all,

I have the following requirement:

1) If a users selects P1 or P2 as the incident priority the user is alerted with a pop-up that asks the user to confirm if they want to propse a MI
2) If the user selects continue the Propose a MI workflow is initiated.
So the confirm should only popup if the priority field CHANGES to 1 or 2, and not if it already is 1 or 2.

I have tried using the following onChange client script but does not work.

function onSubmit() {
    var priority = g_form.getValue('priority'); 
    if (priority == 1 || priority == 2) {
 
   var response = confirm('Priority 1 & 2 tickets follow the major incident process. Please confirm that you would like to propose this ticket as a Major Incident.');

   if (response == true){
   
    gsftSubmit(null, g_form.getFormElement(), 'sysverb_mim_propose'); //MUST call the 'Action name' set in this UI Action
   
   } else {
  // If cancel is pressed or the dialog is closed the response is empty	
   return false; 
   }
   }
}

the confirm function works and it pops up but the UI action does not trigger.

Please advise.

1 ACCEPTED SOLUTION

Can you switch this to onChange? 

View solution in original post

39 REPLIES 39

Khalnayak
Tera Guru

@Ankur Bawiskar  can you help  please

Hi,

Did you try to add some debug statements or alert etc

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar  yes i  did try adding alerts, and all alerts come up, but the gsftsubmit function still not working. see code below with alerts.

function onSubmit() {
    var priority = g_form.getValue('priority'); 
    if (priority == 1 || priority == 2) {
 alert("test inside first if");
   var response = confirm('Priority 1 & 2 tickets follow the major incident process. Please confirm that you would like to propose this ticket as a Major Incident.');
alert("test between ifs");
// If cancel is pressed or the dialog is closed the response is empty	
   if (response == true){
   alert("test inside second if");
    gsftSubmit(null, g_form.getFormElement(), 'sysverb_mim_propose'); //MUST call the 'Action name' set in this UI Action
   alert("test after gsftsubmit");
   } else {
  
   return false; 
   }
   }
}

Hi,

Is your UI action name is correct?

Also please check UI action name is unique across the entire UI actions

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

yes @Ankur Bawiskar the UI action name is correct and have double checked, the UI action name is  unique.

 

find_real_file.png