Script not working in UI action

Akshat2404
Tera Contributor

I am facing an issue while running the script in UI action. The client side script is executed but the server side script is not getting executed even if i use gsftSubmit().

Here is the code: 

function alertUser() {
if (confirm("Are you sure you want to create a child incident of current incident?")) {
alert("your record is created");
gsftSubmit(null, g_form.getFormElement(), 'create_incident');
}
}

if(typeof window == 'undefined')
createChildIncident();



function createChildIncident() {
var g = new GlideRecord('incident');
g.initialize();
g.caller_id = current.caller_id;
grec.parent_incident = current.sys_id;
g.short_description = current.short_description;
g.insert();
action.setRedirectURL(current);
}
7 REPLIES 7

Shruti
Mega Sage
Mega Sage
function alertUser() {
if (confirm("Are you sure you want to create a child incident of current incident?")) {
alert("your record is created");
gsftSubmit(null, g_form.getFormElement(), 'create_incident');
}
}

if(typeof window == 'undefined')
createChildIncident();



function createChildIncident() {
var g = new GlideRecord('incident');
g.initialize();
g.caller_id = current.caller_id;
g.parent_incident = current.sys_id;
g.short_description = current.short_description;
g.insert();
action.setRedirectURL(current);
}

Maddysunil
Kilo Sage

@Akshat2404 

Please try with below code:

 

function alertUser() {
    if (confirm("Are you sure you want to create a child incident of the current incident?")) {
        // Trigger the server-side script to create the child incident
        createChildIncident();
    }
}

// Function to create a child incident
function createChildIncident() {
    var newIncident = new GlideRecord('incident');
    newIncident.initialize();
    newIncident.caller_id = current.caller_id;
    newIncident.parent_incident = current.sys_id;
    newIncident.short_description = current.short_description;
    newIncident.insert();

    // After creating the child incident, redirect the user back to the parent incident
    action.setRedirectURL(current);
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

It is not working same issue is coming, client side script is getting executed but the server side script is not.

 

Hi @Akshat2404 ,

 

Did you update Action name--->"Create_incident" in UI action?

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda