Discovery - How the location field is set for a CISummary<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Discovery sets the Location field on a configuration item (CI) using two methods: the location configured on the discovery schedule, or the location derived from the user assigned to the CI. This article explains both methods, including the business rule and sensor script responsible for each. Note that the exact CI location cannot be fetched by Discovery using a base system feature. Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } ALL Instructions<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Discovery sets the Location field on a CI using two methods. If the location was set by method 1, method 2 will not overwrite it, and vice versa. Method 1 — Location sourced from the assigned user If the CI has an assignee (assigned_to field), Discovery sources the location from that user's Location field after the record is updated. For example, if a user whose Location = "INDIA" is set as the CI's assigned_to, the CI's Location will be set to INDIA. The business rule script responsible for this behaviour: if(!current.assigned_to.location.nil()) { current.location = current.assigned_to.location;} Use the following sample URL to locate the business rule on your instance: <instance-name>.service-now.com/sys_script_list.do?sysparm_query=nameSTARTSWITHUpdate%20location%20as%20needed%5Ecollection%3Dcmdb_ci&sysparm_view= Method 2 — Location sourced from the discovery schedule When a discovery schedule is used to discover the CI, Discovery sets the Location field on the CI from the Location configured on that discovery schedule. If the Location field is not visible on the discovery schedule form, add it to the form view. When a discovery schedule has a Location field populated, all CIs discovered by that schedule will have their Location field set to that value during the discovery run. If the Location field on the discovery schedule is left blank, the Location field on the discovered CIs will remain empty. For Quick Discovery runs, the location is set based on the location of the user who initiated the run. The sensor script responsible for this behaviour retrieves the location of the current discovery and returns the SysID of the location for the current sensor, or null if not found: getLocationID: function() { if (typeof(this._locationID) !== 'undefined') // initialized on demand by this method. return this._locationID; this._locationID = null; // initialize var scheduleGr = new GlideRecord('discovery_schedule'); if (!scheduleGr.get(g_status.scheduleID)) return null; if (!scheduleGr.location) return null; this._locationID = ''+scheduleGr.location.sys_id; return this._locationID; Use the following sample URL to access the sensor script on your instance: <instance-name>.service-now.com/nav_to.do?uri=%2Fsys_script_include.do%3Fsys_id%3D778011130a0a0b2500c4595ad1d1d768 Note: The exact CI location cannot be fetched by Discovery using a base system feature. Related Links<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } How to pass discovery schedule fields to a CI record via discovery What changes the Location attribute on CMDB CI records?