https://docs.microsoft.com/en-us/azure/active-directory/active-directory-saas-servicenow-tutorial
Sunday, March 11, 2018
Wednesday, February 14, 2018
Create a user approval through script in ServiceNow workflow
var approval_gr = new GlideRecord('sysapproval_approver');
approval_gr.initialize();
approval_gr.state = 'requested';
approval_gr.approver = gs.getUserID();
approval_gr.sysapproval = current.sys_id;
approval_gr.insert();
The approver and sysapproval columns should be replaced according to your required values.
The approver and sysapproval columns should be replaced according to your required values.
Monday, February 12, 2018
Make attachment mandatory for catalog item submission
We can use the following catalog client script onSubmit
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", g_form.getUniqueValue());
gr.query();
if (!gr.next()) {
alert("Attachment mandatory.");
return false;
}
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", g_form.getUniqueValue());
gr.query();
if (!gr.next()) {
alert("Attachment mandatory.");
return false;
}
Friday, February 9, 2018
Cancel a workflow using a script when any one of RITM approvals are rejected | ServiceNow
Use the following script in the run script activity of the current workflow
answer = true;
var sag = new GlideRecord('sysapproval_group');
sag.addQuery('parent', current.sys_id);
sag.query();
while(sag.next()) {
if(sag.approval == 'rejected') {
current.state = '4';
var w = new Workflow();
var gr = new GlideRecord('wf_context');
if (gr.get(current.context))
w.cancelContext(gr);
}
}
answer = true;
var sag = new GlideRecord('sysapproval_group');
sag.addQuery('parent', current.sys_id);
sag.query();
while(sag.next()) {
if(sag.approval == 'rejected') {
current.state = '4';
var w = new Workflow();
var gr = new GlideRecord('wf_context');
if (gr.get(current.context))
w.cancelContext(gr);
}
}
Tuesday, January 30, 2018
Monday, January 29, 2018
Sample code to get the catalog variables in the ServiceNow workflow
var gr = current ;
var firstName = gr.variables['first_name'] ;
var lastName = gr.variables['last_name'] ;
var fullName = lastName.getGlideObject().getValue() + " " + firstName.getGlideObject().getValue() ;
var firstName = gr.variables['first_name'] ;
var lastName = gr.variables['last_name'] ;
var fullName = lastName.getGlideObject().getValue() + " " + firstName.getGlideObject().getValue() ;
Sample code to restart servicenow workflow
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', 'RITM0106387');
gr.query();
if(gr.next()) {
var w = new Workflow();
var context = w.startFlow('67755686db2c4b004620d2c75e96191e', gr, 'insert', '');
}
gr.addQuery('number', 'RITM0106387');
gr.query();
if(gr.next()) {
var w = new Workflow();
var context = w.startFlow('67755686db2c4b004620d2c75e96191e', gr, 'insert', '');
}
Subscribe to:
Posts (Atom)
