By default catalog client scripts and catalog UI policies are not visible on the form, they can be added from the related lists section
Friday, September 22, 2017
Tuesday, August 22, 2017
What happens to the currently running workflow if new changes are made to the workflow
Once a record triggers a workflow, it keeps the original context version through the life of the flow. Only new workflow contexts created after you publish the change will use the new flow.
When a new version of an existing workflow is published, the changes are not applied to running workflow contexts. Any currently running workflow context continues using the workflow version that was available when the workflow started. The next time the workflow runs, it uses the updated, published version.
Auto close standard change/incidents after 5 days
The following script can be schedule to auto close the standard changes/incidents after 5 days to auto close
var changeGR = new GlideRecord('change_request');
changeGR.addQuery('type', 'Standard');
changeGR.addQuery('state', 0);
changeGR.query();
while(changeGR.next()) {
var dif = gs.calDateDiff(changeGR.sys_updated_on, gs.nowDateTime(), true);
gs.print(changeGR.number);
if(dif >= 5*86400){
changeGR.state = 3;
changeGR.comments = 'Change Request automatically closed after 5 days in the Review state.';
changeGR.active = false;
changeGR.update();
}
}
var changeGR = new GlideRecord('change_request');
changeGR.addQuery('type', 'Standard');
changeGR.addQuery('state', 0);
changeGR.query();
while(changeGR.next()) {
var dif = gs.calDateDiff(changeGR.sys_updated_on, gs.nowDateTime(), true);
gs.print(changeGR.number);
if(dif >= 5*86400){
changeGR.state = 3;
changeGR.comments = 'Change Request automatically closed after 5 days in the Review state.';
changeGR.active = false;
changeGR.update();
}
}
Thursday, July 27, 2017
All about Duplicate configuration Items in SNOW CMDB
The Problem with Duplicate CIs
Duplicate configuration items are a serious problem for any Configuration Management Database:
- Inaccurate inventory asset reports
- Could cost your company money on new licenses and maintenance
- Creates confusion when users are submitting ticket requests
- Makes it difficult to report on incident, change and problem trends
- Makes configuration management more difficult
- Can undermine the trust in configuration management
Getting rid of duplicate CIs is always a high priority for any configuration management team.
ServiceNow Discovery Preventing Duplicates
Each configuration item record is uniquely identified based on one or more field values specified in a CI Identifier Rule. A configuration item record is considered duplicate if the field values that uniquely identify it match the field values of another record of the same class. By default, configuration items of class Hardware and all subclasses (Computer, Server, Unix Server, Windows Server) use the OS Serial Number as a unique identifier. When SN Discovery or Service Mapping discovers a CI, the sensors and patterns use the internal function SNC.IdentificationEngineScriptableApi.createOrUpdateCI to send the CI to the CMDB. If a CI already exists with the identifier attributes for that particular class, it is overwritten, otherwise a new CI is inserted. Here is sample JavaScript code invoking this function:
_________________________________________________________________________
var payload = {
items: [{
className: 'cmdb_ci_aix_server',
values: {
name: 'Aix Server 900',
asset_tag: 'Asset 900',
ip_address: '10.20.30.11',
mac_address: 'ABCD1234',
ram: '4096',
cpu_name: 'SNow',
serial_number: '123456783',
cpu_type: 'SNow'
}
}]
};
var jsonUtil = new JSON();
var input = jsonUtil.encode(payload);
var output = SNC.IdentificationEngineScriptableApi.createOrUpdateCI ( 'ServiceNow', input);
- gs.print ( output)
Wednesday, June 7, 2017
Avoid duplicate incidents or stop processing inbound email actions further
Sometimes we observe that the system is creating multiple emails for an email received. This could be because multiple Inbound Email Actions have the same matching condition. All the inbound actions for which the condition is met will be executed and a record is created in that table.
We can avoid this by programmatically stopping the ServiceNow system to stop processing the further inbound actions
We can avoid this by programmatically stopping the ServiceNow system to stop processing the further inbound actions
Wednesday, May 17, 2017
UI Macro for the ProgressBar - Jelly Scripting
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_renderer" value="SimpleProgressBar"/>
<g:evaluate var="jvar_choices" jelly="true" object="true">
// get the api
var api = new SNC.RendererAPI('$[jvar_renderer]');
var showValue = api.getOption('showValue')+'';
// build the full set of choices including subflows
var choices = api.getParentWorkflowChoices(current, jelly.jvar_ref);
choices;
</g:evaluate>
<g:evaluate var="jvar_increment" jelly="true" >
var increment = 100.00 / choices.getSize();
var percentComplete = 0;
var atEnd = true;
for (var i = 0; choices.getSize() > i; i++) {
percentComplete += increment;
if (choices.getChoice(i).getParameter('state')+'' === 'active') {
atEnd = false;
break;
}
}
percentComplete = atEnd ? 100 : parseInt(percentComplete);
increment;
</g:evaluate>
<j:set var="jvar_t" value="$[jvar_ref]" />
<table id="workflow.progress" border="1" cellpadding="0" cellspacing="0"
style="width:100%; margin-top: 2px; background-color: transparent;" >
<j:if test="$[showValue]">
<tr>
<td colspan="${choices.getSize()}" style="width:100%; font-size:10px; border:none; text-align:center; background: #000066 url('progress_pctnotdone.gifx') repeat-x;">
${showValue==='true' ? percentComplete+'%' : ' '}
</td>
</tr>
</j:if>
<tr id="progress">
<j:forEach var="jvar_choice" items="$[jvar_choices]">
<g:evaluate var="jvar_choice_visible" jelly="true">
var isVisible = true;
if (!api.getOption('showSkipped'))
if (jelly.jvar_choice.getParameter('state')+'' == 'skipped')
isVisible = false;
if (jelly.jvar_choice.value == '')
isVisible = false;
isVisible;
</g:evaluate>
<g:evaluate var="jvar_image" jelly="true">
var imgsrc = 'progress_pctnotdone.gifx';
if (jelly.jvar_choice.getParameter('state')+'' != 'pending')
imgsrc = 'progress_pctdone.gifx';
imgsrc;
</g:evaluate>
<j:if test="$[jvar_choice_visible]">
<td nowrap="true" style="width:${jvar_increment}%; border-left:none; border-top:none; border-bottom:none; border-right: 1px solid white; background: #000066 url('${imgsrc}') repeat-x;">
$[SP]
</td>
</j:if>
</j:forEach>
</tr>
</table>
</j:jelly>
<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_renderer" value="SimpleProgressBar"/>
<g:evaluate var="jvar_choices" jelly="true" object="true">
// get the api
var api = new SNC.RendererAPI('$[jvar_renderer]');
var showValue = api.getOption('showValue')+'';
// build the full set of choices including subflows
var choices = api.getParentWorkflowChoices(current, jelly.jvar_ref);
choices;
</g:evaluate>
<g:evaluate var="jvar_increment" jelly="true" >
var increment = 100.00 / choices.getSize();
var percentComplete = 0;
var atEnd = true;
for (var i = 0; choices.getSize() > i; i++) {
percentComplete += increment;
if (choices.getChoice(i).getParameter('state')+'' === 'active') {
atEnd = false;
break;
}
}
percentComplete = atEnd ? 100 : parseInt(percentComplete);
increment;
</g:evaluate>
<j:set var="jvar_t" value="$[jvar_ref]" />
<table id="workflow.progress" border="1" cellpadding="0" cellspacing="0"
style="width:100%; margin-top: 2px; background-color: transparent;" >
<j:if test="$[showValue]">
<tr>
<td colspan="${choices.getSize()}" style="width:100%; font-size:10px; border:none; text-align:center; background: #000066 url('progress_pctnotdone.gifx') repeat-x;">
${showValue==='true' ? percentComplete+'%' : ' '}
</td>
</tr>
</j:if>
<tr id="progress">
<j:forEach var="jvar_choice" items="$[jvar_choices]">
<g:evaluate var="jvar_choice_visible" jelly="true">
var isVisible = true;
if (!api.getOption('showSkipped'))
if (jelly.jvar_choice.getParameter('state')+'' == 'skipped')
isVisible = false;
if (jelly.jvar_choice.value == '')
isVisible = false;
isVisible;
</g:evaluate>
<g:evaluate var="jvar_image" jelly="true">
var imgsrc = 'progress_pctnotdone.gifx';
if (jelly.jvar_choice.getParameter('state')+'' != 'pending')
imgsrc = 'progress_pctdone.gifx';
imgsrc;
</g:evaluate>
<j:if test="$[jvar_choice_visible]">
<td nowrap="true" style="width:${jvar_increment}%; border-left:none; border-top:none; border-bottom:none; border-right: 1px solid white; background: #000066 url('${imgsrc}') repeat-x;">
$[SP]
</td>
</j:if>
</j:forEach>
</tr>
</table>
</j:jelly>
Mark users as VIP based on their Group
var vip_grm = new GlideRecord('sys_user_grmember');
vip_grm.addQuery('group', 'SNVIP');
vip_grm.query();
while (vip_grm.next()) {
var vip_rec = new GlideRecord('sys_user');
vip_rec.addQuery('sys_id', vip_grm.user);
vip_rec.query();
while (vip_rec.next()) {
vip_rec.vip = true;
vip_rec.update();
}
}
Tuesday, May 2, 2017
Code to make document upload mandatory on a record producer
Execute this as a catalog client script on the record producer, onSubmit method
function onSubmit() {
var cat_id = gel('sysparm_item_guid').value;
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "u_ar_package");
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
alert("You must upload a package prior to submitting.");
return false;
}else if(gr.next()){
return true;
}
}
function onSubmit() {
var cat_id = gel('sysparm_item_guid').value;
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "u_ar_package");
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
alert("You must upload a package prior to submitting.");
return false;
}else if(gr.next()){
return true;
}
}
Wednesday, April 19, 2017
Retrieve the URL parameters in the ServiceNow Scripting
var billingCode = getParmVal('sysparm_number');
function getParmVal(name) {
var url = document.URL.parseQuery();
if (url[name]) {
return decodeURI(url[name]);
} else {
return;
}
}
Thursday, April 6, 2017
What user name and password we should give during ServiceNow MID Server configuration?
We know that Service/Deamon that facilitates the communication between ServiceNow instance and external Services/Data Sources.
During the configuration of agent/config.xml we need to give the username and password. For that
- Create a new user say SNCMidServerDev1
- Assign the mid_server role to the user (Not the admin role and never)
- Just the mid_server role is sufficient
- Use those credentials in the Midserver configuration
Sunday, March 12, 2017
Howmay types of users we have in ServiceNow?
We have 3 types of users in SNOW
1. ESS Users: Employee Self Service Users
2. ITIL Users
3. Administrators
1. ESS Users: Employee Self Service Users
2. ITIL Users
3. Administrators
Subscribe to:
Posts (Atom)