UI Action not working on single click ,double click only it's working

Raj90
Tera Guru

Hi All,

I have created one UI Action button on the Contract form. When we click on UI Button then the status is changed from "Draft" to "Under review".

This UI button we saw when Status in "Draft" only.

The problem is When we click(1st time) on "Send for Approval" button status is not changing, Again we click on(2nd time) "Send for Approval" button then the Status is changed from "Draft" to "Under review".

find_real_file.png

The below one is UI Action:

find_real_file.png

 

Thanks

11 REPLIES 11

Hi Raj,

This is strange. but did you check whether logs are coming twice i.e. whether UI action code is actually running twice?

Can you wrap the code inside a function and call that function

updateValue();

function updateValue(){

var attachmentGr = new GlideRecord('sys_attachment');
attachmentGr.addQuery('table_sys_id', current.sys_id);
attachmentGr.query();
gs.log("Test1");
if(attachmentGr.next()) {
current.u_status = "Under review";
//current.insert();
gs.log("Test2");
current.update();
//current.setAbortAction(false);
action.setRedirectURL(current);
gs.log("Test3");
}
else
{
gs.log("Test4");
gs.addErrorMessage("Please attach a file as an attachment");
current.setAbortAction(true);
gs.log("Test5");
action.setRedirectURL(current);
gs.log("Test6");
}

}

Regards

Ankur

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

 Logs running 2 times.

When we click on(1st) the Ui button then  in the log we saw 1 and again we click on UI button then we saw in logs 2

find_real_file.png

Thanks

Hi Raj,

The time difference between the logs is approx 50 seconds

Regards

Ankur

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

Actually when we click on Send for Approval button we are getting the below logs. --1st time Click 

find_real_file.png

 

when we click on Send for Approval button we are getting the below logs. --2nd time we Click on UI button  

 

find_real_file.png

 

 

Hi Raj,

I believe the null pointer exception is causing the issue. Can you add try catch block and see

function updateValue(){

try{

var attachmentGr = new GlideRecord('sys_attachment');
attachmentGr.addQuery('table_sys_id', current.sys_id);
attachmentGr.query();
gs.log("Test1");
if(attachmentGr.next()) {
current.u_status = "Under review";
//current.insert();
gs.log("Test2");
current.update();
//current.setAbortAction(false);
action.setRedirectURL(current);
gs.log("Test3");
}
else
{
gs.log("Test4");
gs.addErrorMessage("Please attach a file as an attachment");
current.setAbortAction(true);
gs.log("Test5");
action.setRedirectURL(current);
gs.log("Test6");
}

}

catch(ex){

gs.log("Exception message is: "+ ex);

}

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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