answer = (function transformEntry(source) {
function toHex(d) {
return ("0" + Number(d).toString(16)).slice(-2).toUpperCase();
}
function a2b(a) {
var b, c, d, e = {},
f = 0,
g = 0,
h = "",
i = String.fromCharCode,
j = a.length;
for (b = 0; 64 > b; b++) e["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(b)] = b;
for (c = 0; j > c; c++)
for (b = e[a.charAt(c)], f = (f << 6) + b, g += 6; g >= 8;)((d = 255 & f >>> (g -= 8)) || j - 2 > c) && (h += i(d));
return h;
}
function arrayToGuid(arr) {
return arr.slice(0, 4).reverse().join('').toLowerCase() + '-' + arr.slice(4, 6).reverse().join('').toLowerCase() + '-' + arr.slice(6, 8).reverse().join('').toLowerCase() + '-' + arr.slice(8, 10).join('').toLowerCase() + '-' + arr.slice(10, 16).join('').toLowerCase();
}
function base64StringToGuid(base64string) {
var charArray = GlideStringUtil.base64Decode(base64string).split('').map(function(el) {
return el.charCodeAt(0);
}).map(function(el) {
return toHex(el);
});
return arrayToGuid(charArray);
}
return base64StringToGuid(source.u_objectguid); // return the value to be put into the target field
})(source);
Tuesday, June 26, 2018
Convert LDAP attribute objectGUID from base64 to string in ServiceNow LDAP integration - Transform script
Friday, May 25, 2018
Backend script to logout a user from ServiceNow - SNOW user logout script
var sessions = GlideSessions.get().getLoggedInSessionList();
var it = sessions.iterator();
while(it.hasNext()) {
var session = it.next();
if (session.getUser() == gs.getUserName()) {
var httpSession = session.getHS();
httpSession.setAttribute("locked_out", "true");
}
}
var it = sessions.iterator();
while(it.hasNext()) {
var session = it.next();
if (session.getUser() == gs.getUserName()) {
var httpSession = session.getHS();
httpSession.setAttribute("locked_out", "true");
}
}
Monday, April 16, 2018
Custom Glyph in ServiceNow portal - Icon Link widget
Step1: You have to upload the image to image to the table db_image
Step2: Clone the widget Icon Link
Step3: Html code is as below
<div>
<!--// Top Icon -->
<a ng-if="::(options.link_template == 'Glyph Icon' || !options.link_template)" ng-href="{{::data.href}}" class="glyph_icon {{::options.class_name}}" target="{{::data.target}}">
<div class="m-b fa fa-{{::options.glyph}} fa-4x {{::options.class_name}} text-{{::options.color}}" align="center" style="margin-right: auto; margin-left: auto; display: block;"></div>
<h4 style="text-align: center;">{{::options.title}}</h4>
<span class="text-muted">{{::options.short_description}}</span>
<p> </p>
</a>
<!--// Image Icon -->
<a ng-if="::(options.link_template == 'Image Icon')" ng-href="{{::data.href}}" class="image_icon {{::options.class_name}} text-{{::options.color}}" target="{{::data.target}}">
<div><img src="{{data.image}}" alt="" align="left" style="margin-right: 7px; margin-left: auto; display: block;"/>
<h3 style="font-weight: 300; margin-top: 22px">{{::options.title}}</h3>
<span class="text-muted">{{::options.short_description}}</span></div>
<p> </p>
</a>
</div>
Step4: Server side coding
(function(){
var gr = $sp.getInstanceRecord();
data.href = $sp.getMenuHREF(gr);
data.target = options.target || "";
var img = new GlideRecord('db_image');
img.addQuery('name', 'custom_icon.png');
img.query();
if (img.next()){
data.image = img.getValue('name');
}
})();
Thursday, April 12, 2018
What is the difference between setVisible() and setDisplay() on g_form?
setDisplay() - It will reclaim the space if the field is hidden on the form
If the field is hidden, the space is used to display other items. that means below field like, if sub status of the incident is not displaying then assignment group will display on that blank space.
setVisible()
If the field is hidden, the space is left blank.you can see the change on the form clearly.
Wednesday, April 4, 2018
LDAP integration vs. SSO ServiceNow what is the difference?
LDAP integration means that your Service-Now instance will pick up newly created Users from the Active Directory, either through Listener ports or through Scheduled Uploads, and when you authenticate yourself while Logging onto Service-Now, this authentication is happening from the AD.
SSO implemented means that you do not have to re-authenticate yourself when trying to access ServiceNow, once you log into an Environment while accessing different Applications for whom SSO is enabled
Wednesday, March 28, 2018
Make all form fields read only - ServiceNow Client Script
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
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();
Subscribe to:
Posts (Atom)