- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2016 01:21 PM
Hey Folks,
I'm looking for a bit of help with populating a cmdb_ci_computer field via an SCCM integration.
I have an integration which works fine for most fields (computer name, serial number, os, etc etc).
However, I'm having trouble populating a "Business Unit" field in cmdb_ci_computer which is referenced to a custom table u_business_unit.
The idea is that if a computer belongs to Domain_1 (which comes across in the OS Domain field), the business unit is set to Business_Unit_1. If the computer belongs to Domain_2 then the business unit is set to Business_Unit_2.
The script that I am trying to use in the transform map field works to populate free text fields (such as short_description), but will not populate the u_business_unit field. I tried to use setDisplayValue as well, but couldn't make it work properly. The script is below:
if(source.u_domain == 'domain_1.net'){
target.u_business_unit = "Business_Unit_1";
}
if(source.u_domain == 'domain_2.net'){
target.u_business_unit = "Business_Unit_2";
}
I'm quite new to ServiceNow/Scripting, so I'm probably missing something simple (hopefully!). Any suggestions are most appreciated.
Thanks!
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2016 01:40 PM
On your field mapping for that entry, did you specific a reference value field name? Otherwise it's looking for 'Business_unit_1' in the field that has Display Value checked. You can change the Display value or set the field name in the map where is should find Business_unit_1.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2016 01:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2016 03:00 PM
Thanks Michael.Fry. This has helped to get it working! Much appreciated
I added the field into "Reference value field name". I also changed the script as below.
answer = (function transformEntry(source) {
if(source.u_domain == 'domain_1.net'){
return "Business_Unit_1";
}
if(source.u_domain == 'domain_2.net'){
return "Business_Unit_2";
}
})(source);