Need to display a Dialog Box with Yes / No to Create Problem Ticket for All Priority 1 incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2018 10:36 AM
The below Code has been created to Automatically create a Problem Ticket for all Priority 1 Incidents. But my requirement is a dialog Box to appear with Yes/No. If you click on Yes Pbm tickets gets created. Pls Help me where to insert the Yes/No code in the below give script.
-------------------------------------------------------------------------------------------------
(function executeRule(current, previous /*null when async*/) {
var short_description =current.getValue('short_description');
var gr= new GlideRecord('incident');
gr.addQuery("short_description", short_description);
gr.query();
var prob = new GlideRecord('problem');
while(gr.next()){
prob.short_description = current.short_description;
prob.impact = current.impact;
prob.urgency = current.urgency;
prob.company = current.company;
prob.setValue('location', current.location);
prob.setValue('cmdb_ci', current.cmdb_ci);
prob.setValue('u_vendor_company', current.u_vendor_name);
prob.setValue('u_vendor_ticket_number', current.u_vendor_ticket_number);
// prob.setCategory(current.category);
prob.setValue('u_category', current.category);
var sysID = prob.insert();
current.problem_id = sysID;
var mySysID = current.update(); // where is the mySysID being used??
}
var url = 'problem.do?sys_id=' + current.problem_id;
// gs.addInfoMessage("A Problem Ticket has been created " + prob.getValue('number'));
/* creating a URL link to the newly created Problem ticket */
gs.addInfoMessage('A Problem Ticket has been created: '+
"<a href='" + url + "'>" +
prob.getValue(prob.getDisplayName()) +
"</a>" + '.');
})(current, previous);
----------------------------------------------------------------------------------------------------------------
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2018 11:45 AM
Hi, please
can you wruite this code for conformation box
var txt;
var r = confirm("You want to submit the record then please click on Ok Button otherwise Cancle");
if (r == true) {
txt = "OK Button";
} else {
return false;
}
Please mark it if it is helpful for you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2018 11:45 AM
You'd need to use a UI action for this. Ensure the client checkbox is checked and then write client side code to show standard JavaScript confirm prompt, this would then call server side script - though this would only give you an OK cancel option, not yes/no. Here is an example;
function confirmCreateProblem(){
var response = confirm('Do you wish to create a Problem?');
//If cancel is pressed or the dialog is closed the response is empty
if (!response){
return;
}
gsftSubmit(null, g_form.getFormElement(), 'create_problem'); //MUST call the 'Action name' set in this UI Action
}
if (typeof window == 'undefined'){
createProblem();
}
function createProblem(){
//[ADD SERVER SIDE CODE TO CREATE PROBLEM RECORD]
action.setRedirectURL(current);
}
You could achieve this with a bit more work by creating a UI page and then using GlideDialogWindow but that's quite a bit more work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2018 11:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2018 12:10 PM
Hi Vasant,
Below code may be helpful, add more to it according to your requirement.
//Create an onSubmit Client Script
function onSubmit() {
var priority = g_form.getValue('priority');
if(priority == '1')
{
var response = confirm("Do you want to create a Problem record ??");
if(response)
{
var ga = new GlideAjax('u_Create_Problem_P1Incidents');//name of script include
ga.addParam('sysparm_name', 'insertProblem');//name of function on script include
ga.addParam('sysparm_inc_number', g_form.getValue('number'));//Pasing Current Incident number
ga.addParam('sysparm_short_description', g_form.getValue('short_description'));
//Similarly pass other fields to Script Include
}
else
{
return false;
}
}
------------------------------------------------------------------------------------
// Create a new Script Include
Name : u_Create_Problem_P1Incidents
Define a function in it as below
insertUserRecord: function(){
var inc_number = this.getParameter('sysparm_inc_number');
var short_description = this.getParameter('sysparm_short_description');
// Create a new Problem record
var gr = new GlideRecord('problem');
gr.initialize();
gr.short_description = short_description;
//Similarly set other fields
gr.insert();
Mark If Correct/Helpful.
Regards,
Ajay