Pop Up confirmation message in UI action does not work for creating incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2023 02:07 AM
Hi,
I have created a UI action 'Create Incident' on the HR case and it was working fine. Additionally, I wanted to add a pop-up confirmation message and clicking OK should let the user create an incident or else stay on the same form. But this code does not run and clicking on UI action is not creating any incident. Please have a look at the code I used below and help me understand what is wrong with it.
/****************************************************************************************************************?
Thanks in Advance,
RS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2023 02:22 AM
I think you are missing this statement.
gr.initialize();
can you please try with below code?
function createInci() {
var answer = confirm("Are you sure that you want to go ahead with creating an incident");
if (answer == 'true') {
gsftSubmit(null, g_form.getFormElement(), 'createInc');
} else {
return false;
}
if (typeof window == 'undefined')
resolveIncidentFunction();
function resolveIncidentFunction() {
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = current.opened_for;
gr.short_description = current.short_description;
gr.description = current.rich_description;
var inc = gr.insert();
GlideSysAttachment.copy('sn_hr_core_case', current.sys_id, 'incident', inc); //copies attachment if any can be commented if required.
current.update();
action.setRedirectURL(gr);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2023 02:40 AM
Harshad,
Thank You for the suggestion. I tried but it did not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2023 02:58 AM
do you see any error? if you go to incident table does it show any new records?
Can you please update the script and see if there are any logs getting generated?
function createInci() {
var answer = confirm("Are you sure that you want to go ahead with creating an incident");
if (answer == 'true') {
gsftSubmit(null, g_form.getFormElement(), 'createInc');
} else {
return false;
}
if (typeof window == 'undefined')
resolveIncidentFunction();
function resolveIncidentFunction() {
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = current.opened_for;
gr.short_description = current.short_description;
gr.description = current.rich_description;
var inc = gr.insert();
gs,log("POPUP" + inc );
GlideSysAttachment.copy('sn_hr_core_case', current.sys_id, 'incident', inc); //copies attachment if any can be commented if required.
current.update();
action.setRedirectURL(gr);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2023 03:20 AM
Harshad, Yes I used info messages and found that the server-side script is not running.
And no incident was created in the backend either.