UI Action not working on single click ,double click only it's working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 12:10 AM
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".
The below one is UI Action:
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 02:05 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 02:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 02:26 AM
Hi Raj,
The time difference between the logs is approx 50 seconds
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 02:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 04:50 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader