How to disable SCCM Integration changing the 'Assigned To' field?

Antti Luusua
Kilo Guru

Hello SNow Community,

 

sorry if my question has already been answered but couldn't find any help while searching these forums or otherwise.

We are trying to migrate using ServiceNow's asset management but have a few hurdles along the way. One of the issues is that our Servicenow has SCCM integration, and while it is working, we would like to manually assign the assets to people. Currently the 'Assigned To' field is set by SCCM Integration by taking the Primary User from SCCM but this is not a 100 % accurate information at all times. We cannot disable this function in SCCM since our Helpdesk uses it in other ways but it should not take any part in SNow asset management.

 

I'm guessing I would have to edit the SQL query and remove the part where it queries SCCM for the user name but I fear that I break something I do that.

 

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION

akash_mehta
ServiceNow Employee
ServiceNow Employee

You don't have to modify the SQL statement; you can bring it in and populate it into another field if you like for reference purpose.

You should make these changes at the Transform Map level...

1) In the SCCM 2016 Computer Identity Transform Map

2) There is a script that runs a function called "runIt();" - in that function there is a "setAssignedTo();" function that you can comment out.

This will stop populating the assigned to value on the CI (and asset since it is synchronized).

Additional thoughts:

1) At other customers, I have created a field on the cmdb_ci_computer table called "Discovered User" or "Primary User" and set this value from the SCCM transform map into this field - it allows you to see what the discovery source thinks is the primary user and compare it

2) I tend to just make this field a string field instead of a reference field - just in case this user is a service account or some sort of admin account that may not be in ServiceNow user table

 

Hope that helps.

-Akash

View solution in original post

9 REPLIES 9

akash_mehta
ServiceNow Employee
ServiceNow Employee

Raj:  you could check the field prior to populating; if it is NULL then populate the assigned_to, otherwise, don't populate assigned_to.  I believe you will need to either query or you can try to check JSUtil.nil(target.assigned_to) or something like that.

 

But @akash.mehta i am telling you that for the first time i want to set the assigned to field when sccm integation takes place than it should stop because it automatically assigns again and again to current user. So what to do for that you are saying to keep nil value?

akash_mehta
ServiceNow Employee
ServiceNow Employee

Raj:  No, I am saying in the transform map you will need to look at the target.assigned_to -> if this value is NULL, then populate the assigned to value from SCCM.  If this value is not null, then ignore the mapping for assigned to.

-Akash

@akash.mehta so this is the script of computer identity transform map. Here i want the assigned to field should be there and should assign only once not every time the user goes to the record so please tell what to do

runIt();

function runIt() {
setMakeAndModel();
determineClass();
setAssignedTo();
setCorrelationID();
}

function setMakeAndModel() {
var mm = MakeAndModelJS.fromNames(source.u_manufacturer, source.u_model, "hardware");
target.model_id = mm.getModelNameSysID();
target.manufacturer = mm.getManufacturerSysID();
}

function determineClass() {
// Determine the class of the target CI
if (source.u_systemrole == "Workstation")
target.sys_class_name = "cmdb_ci_computer";
else
target.sys_class_name = "cmdb_ci_win_server";
}

function setAssignedTo() {
var userName = source.u_username;
if (JSUtil.nil(userName))
return;

var x = userName.indexOf("\\");
if (x > -1)
userName = userName.substring(x + 1);

var nameField = gs.getProperty('glide.discovery.assigned_user_match_field', "user_name");
target.assigned_to = GlideUser.getSysId(nameField, userName);
}

/* This function fixes the fact that when transforming a integer to a string field, it includes the commas
* Also, this is the old style of setting the resource_id. The onAfter script sets it in the Object Source table.
*/
function setCorrelationID() {
target.correlation_id = source.u_resourceid + '';
}

Hi Akash ,

we have a requirement that 

Stop SCCM sync of 'Assigned to' field for only Windows Server class

 

Any help would be greatly appreciated!.