- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2021 09:37 PM
if(current.close_notes.nil()){
gs.addErrorMessage(gs.getMessage("Please specify a resolution note."));
action.setRedirectURL(current);
current.setAbortAction(true);
}
// else if(current.u_resolution_type.nil()){
// gs.addErrorMessage(gs.getMessage("Please specify a resolution type."));
// action.setRedirectURL(current);
// current.setAbortAction(true);
// }
else if(current.resolution_code.nil()){
gs.addErrorMessage(gs.getMessage("Please specify a resolution code."));
action.setRedirectURL(current);
current.setAbortAction(true);
}
else{
if (current.contact_type == 'hg_analytics'){
current.u_alert_investigation = current.u_alert_investigation_pre_qc;
}
if(current.resolution_code == 9){
setCaseLog(current.number, current.state, current.u_substate, 6, 6, current.contact_type);
current.u_substate = 6;
}else{
setCaseLog(current.number, current.state, current.u_substate, 6, 7, current.contact_type);
}
current.resolved_by = gs.getUserID();
current.state = 6;
current.u_resolve_timestamp = new GlideDateTime();
current.resolved_at = new GlideDateTime();
current.update();
action.setRedirectURL(current);
}
function Resolve(){
var dte = g_form.getValue('u_work_in_progress_time');
var ga = new GlideAjax('CalculateDiff');
ga.addParam('sysparm_name', 'getDurationFromNow');
ga.addParam('sysparm_sdate', dte);
ga.getXMLWait();
var answer = ga.getAnswer(); //getAnswer() retrieves the result for you
var usrResponse = confirm('Are you sure you have spent duration: ' + answer);
if (usrResponse == true) {
//DO nothing
} else {
return false;
}
}
function setCaseLog(number, from_state, from_substate, to_state, to_substate, stream){
var cslog_gr = new GlideRecord('sn_customerservice_cases_log');
cslog_gr.initialize();
cslog_gr.u_case = number;
cslog_gr.u_from_state = from_state;
cslog_gr.u_from_substate = from_substate;
cslog_gr.u_to_state = to_state;
cslog_gr.u_to_substate = to_substate;
cslog_gr.u_stream = stream;
cslog_gr.insert();
}
On Click - Resolve()
Ui Action - is in scope application,
Script include is in global domain,
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2021 10:27 PM
Hi Vibha,
1. As you mentioned the UI Action is in scope application and you are calling global script include. Make sure your script include is accessible in other scopes (value on form should be All Application scope).
2. When you call script include from different scope you need to use API Name, instead of Name. e.g. var ga = new GlideAjax('global.getAlertURL ');
3. IF your UI action is performing both server and Client side operation then make sure to call UI Action Name uisng gsftSubmit();
check below links to know more about gsftSubmit and uses:
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
After doing above changes, make sure to put logs to see where your code stopped working.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2021 09:51 PM
Hi there,
Can you share what debugging you did? Up to which point the UI Action is working? Where the UI Action is failing?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2021 10:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2021 10:22 PM
Hi
please read carefully the following article. It explains how to write the script in the correct way so that your code is working both server-side and client-side.
At the moment, you are mixing server-side and client-side code, which leads to the described non-working state.
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Kind regards
Maik
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2021 10:27 PM
Hi Vibha,
1. As you mentioned the UI Action is in scope application and you are calling global script include. Make sure your script include is accessible in other scopes (value on form should be All Application scope).
2. When you call script include from different scope you need to use API Name, instead of Name. e.g. var ga = new GlideAjax('global.getAlertURL ');
3. IF your UI action is performing both server and Client side operation then make sure to call UI Action Name uisng gsftSubmit();
check below links to know more about gsftSubmit and uses:
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
After doing above changes, make sure to put logs to see where your code stopped working.
Thanks,
Anil Lande
Thanks
Anil Lande