var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
Wednesday, March 28, 2018
Make all form fields read only - ServiceNow Client Script
Thursday, March 22, 2018
ServiceNow group approval through workflow script
var approval_gr = new GlideRecord('sysapproval_group');
approval_gr.initialize();
approval_gr.approval = 'requested';
approval_gr.parent = current.sys_id;
approval_gr.assignment_group = current.assignment_group;
approval_gr.short_description = 'Change Management Approval';
approval_gr.wait_for = 'any';
approval_gr.insert();
Sunday, March 11, 2018
SSO - ServiceNow integration with Microsoft Azure AD
https://docs.microsoft.com/en-us/azure/active-directory/active-directory-saas-servicenow-tutorial
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
Subscribe to:
Posts (Atom)
