client script

Anjali yadav1
Tera Contributor

scenario on incident form I want to show a pop with OK or Cancel if click on OK, an incident will be created if click on Cancel not able to create an incident what is the approach to achieve this? 

 

1 ACCEPTED SOLUTION

SK Chand Basha
Giga Sage

Hi @Anjali yadav1 Use on submit client script you can achieve this functionality

I have tested in my PDI attached screenshot below.

 

Mark it Helpfull and Accept the Solution . If this helps you to understand.

View solution in original post

5 REPLIES 5

Sonam_Tiwari
Kilo Sage

Hi @Anjali yadav1 ,

 

var con = confirm("<Message in your confirm box>");
if (con == true) {
// raise the incident
} else {

//cancel case
    return false;
}

 

Try something like this.

 

 

Consider indicating the response as helpful and marking it as correct if it meets your needs.

hello thanks for replying,

Should I use the code in the client script or in the script blank (system definition)?

SN_Learn
Kilo Patron
Kilo Patron

Hi @Anjali yadav1 ,

 

You can achieve this by using the 'confirm' in the script of the UI action. 

Note: You need to check the client checkbox to true to utilize this.

 

Sample code is as below:

var ans = confirm('Do you want to create an Incident?');
    if (ans == true) {
        var newIncRec = new GlideRecord("incident");
        newIncRec.initialize();
        newIncRec.setValue("caller_id", g_user.getUserID());
       // newIncRec.setValue("short_description","TestDescription");
	newIncRec.insert();
}
else {
    return false;
}

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

SK Chand Basha
Giga Sage

Hi @Anjali yadav1 Use on submit client script you can achieve this functionality

I have tested in my PDI attached screenshot below.

 

Mark it Helpfull and Accept the Solution . If this helps you to understand.