Skip to content

Instantly share code, notes, and snippets.

@afaulkinberry
Last active August 29, 2015 14:26
Show Gist options
  • Save afaulkinberry/38fc6de922d6c20355ad to your computer and use it in GitHub Desktop.
Save afaulkinberry/38fc6de922d6c20355ad to your computer and use it in GitHub Desktop.
ServiceNow - Glide System
function onSubmit() {
var alrtMsg = null;
var kWords = g_form.getValue('short_description');
var ga = new GlideAjax('CheckKnownIssues'); //Use the name of the Script Include
ga.addParam('sysparm_name', 'findKeywords'); //findKeywords is a function in the include
ga.addParam('sysparm_keyWrds', kWords ); //kWords is a variable in the include (var kywrds = this.getParameter('sysparm_keyWrds');)
ga.getXMLWait(); //Wait on the script to complete
alrtMsg = ga.getAnswer(); //Get the returned value from the Script Include
if (alrtMsg != null) {
return confirm(alrtMsg + "\n\n" + "Please click \"OK\" if you would still like to submit this reqest.");
}
}
//Use two glide records to create new record from parent record while including attachments
createCSCase();
function createCSCase() {
var gr = new GlideRecord('u_cases');
gr.get(current.u_parent_case); //Parent Case sys_id
var csCase = new GlideRecord('u_cs_cases');
csCase.u_guest_name = gr.u_contact_name;
csCase.u_contact_name = gr.u_contact_name;
csCase.u_phone = gr.u_contact_name.u_phone;
csCase.u_e_mail = gr.u_contact_name.u_e_mail;
csCase.short_description = gr.getValue('short_description');
csCase.location = gr.location;
csCase.u_arrival_date = gr.u_arrival_date;
csCase.u_departure_date = gr.u_departure_date;
csCase.assignment_group = 'b5e124630a0a3c10054be70ba3d6c288'; //New Assignment Group sys_id
csCase.assigned_to = null; //u_cs_case assigns to record creator by default.
csCase.work_notes = gr.work_notes.getJournalEntry(-1); //Copy all worknotes and comments to new record.
csCase.insert();
gs.sleep(1000);
GlideSysAttachment.copy('u_cases', gr.sys_id, 'u_cs_cases', csCase.sys_id);
gs.addInfoMessage("HSSC CS Case " + csCase.number + " has been created.");
current.state.setValue(3);
current.active.setValue(false);
gr.state.setValue(3);
gr.active.setValue(false);
gr.update();
}
function gdq() {
var gr = New GlideRecord('incident');
gr.addQuery('assignment_group', 'b5e124630a0a3c10054be70ba3d6c288');
gr.query()
while(gr.next()){
gr.priority = 1;
gr.update();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment