Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

We have built a method to allow the helpdesk to have delegated control over the mapping between Service Contracts and Organizations. They control an Excel spreadsheet, hosted at box.net.

ServiceNow scrapes that location, loads the spreadsheet, parses the six-digit Organization IDs, and updates the contracts.

That should be good enough, but alas, it is not. Backeberg filed INC0109961 about this

ServiceNow has the organization contract and DSP data replicated on the User records. This user data is stale and not dynamically updated by changes to the ORG data. Thus if we make changes to the ORG data we need to force those changes to cascade to the user records associated with that ORG.

Script to manually force-update the cascade so ORG contract data is associated with user records

var orgID='736001';
// set orgID to the ORG where you want to synchronize user ORG records
var debug=true;
var orgSysID = 'declared';
var orgDSPID = 'declared';
var orgContractID = 'declared';

var gr1 = new GlideRecord('u_cmn_organization');
gr1.addQuery('u_id',orgID);
gr1.query();
while ( gr1.next() ) {
 orgSYSID = gr1.sys_id;
 orgDSPID = gr1.u_dsp_group;
 orgContractID = gr1.u_service_contract;
 if (debug) {
  gs.log("organization sysid: "+ gr1.sys_id + " and ORG name: " + gr1.u_name + " and orgSYSID: " + orgSYSID + " and orgDSPID: " + orgDSPID + " and orgContractID: " + orgContractID);
 }
}

var gr2 = new GlideRecord('sys_user');
var memberCount = 0;
var memberArray = [];
gr2.addQuery('u_organization',orgSYSID);
gr2.query();
while ( gr2.next() ) {
 memberCount += 1;
 memberArray.push(gr2.sys_id);
 if ( debug) {
  gs.log("members include: " + gr2.name + " and sysid: " + gr2.sys_id + " and count: " + memberCount);
 }
 var gr3 = new GlideRecord('sys_user');
 gr3.addQuery('sys_id',gr2.sys_id);
 gr3.query();
 while (gr3.next()) {
  gr3.u_dsp_group = orgDSPID;
  gr3.u_service_contract = orgContractID;
  gr3.update();
 }
}
  • No labels