Notifications

10 views

Symptoms


Email address and company values removed upon creating an HR case.

Release


Kingston

Cause


(Set user fields/Update Email Devices) business rules.

Resolution


The (Set User Fields) business rules calls (hr_Case) script include below and sets the users (Company) accordingly:
https://<instance-name>.service-now.com/nav_to.do?uri=sys_script_include.do?sys_id=7a5370019f22120047a2d126c42e7000

setUserFields : function() {
this._logDebug("[setUserFields] Setting user fields kicking off");

// Don't do anything if we're updating and nothing has changed
if (!this._case.opened_for || !this._case.opened_for.changes()) {
this._logDebug("[setUserFields] no changes to opened_for, exiting");
return;
}

// Dereference these fields from opened_for user; set for example, this._case[location]
this._setFromRefField("opened_for", "location");
this._setFromRefField("opened_for", "company");
this._setFromRefField("opened_for", "department");
},

The (email) field is cleared by business rule (Update Email Devices):
https://<instance-name>.service-now.com/nav_to.do?uri=sys_script.do?sys_id=1e9cd29e0a0a0b1d003e3951ebd20b77

var thisSysID = current.sys_id;
var device = new GlideRecord('cmn_notif_device');
device.addQuery('user', thisSysID);
device.addQuery('type', 'Email');
device.addQuery('primary_email', true);
device.query();

while (device.next()) {
gs.log('Updating ' + current.name + '\'s primary email device based on change to user record email address');
device.email_address = current.email;
device.setWorkflow(false);
device.update();
}

Article Information

Last Updated:2018-11-05 02:28:48
Published:2018-11-05