How to replace hardcoded sys_ids in scripts to resolve health scan security flagsIssue <!-- /*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: ; } } Learn how to replace hardcoded sys_ids in scripts with system properties to avoid security flags during ServiceNow instance health scans. ServiceNow performs health scans on instances to identify security issues. Scripts that contain hardcoded sys_ids are flagged during these scans. The resolution is to store sys_ids as system properties and retrieve them using gs.getProperty() rather than embedding them directly in script code. 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 supported releases Resolution<!-- /*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: ; } } Step 1: Identify hardcoded sys_ids in the script Scripts that embed sys_ids directly in encoded query strings are flagged during health scans. The following example shows a script with hardcoded sys_ids — this pattern triggers the security flag: var ciName = new GlideRecord('cmdb_ci'); var encodedquery = 'sys_class_name=cmdb_ci_computer^manufacturer=b7e9e843c0a80169009a5a485bb2a2b5^location=f90735e70a0a0b9100de208fbc63907d^company=31bea3d53790200044e0bfc8bcbe5dec'; ciName.addEncodedQuery(encodedquery); ciName.query(); while (ciName.next()) { gs.print('cmdb_ci.name ' + ciName.name); } Step 2: Create system properties for each sys_id Go to System Properties and create a new property record for each sys_id that appears in the script. In this example, three properties are created: Property NameValueacme_corpb7e9e843c0a80169009a5a485bb2a2b5loc_santa_anaf90735e70a0a0b9100de208fbc63907dacme_ne31bea3d53790200044e0bfc8bcbe5dec Step 3: Update the script to use gs.getProperty() Replace the hardcoded sys_ids in the script with gs.getProperty() calls that retrieve the values from the system properties created in step 2: var acme_corp_SysID = gs.getProperty("acme_corp"); var location_SysID = gs.getProperty("loc_santa_ana"); var company_SysID = gs.getProperty("acme_ne"); var ciName = new GlideRecord('cmdb_ci'); var encodedquery = 'sys_class_name=cmdb_ci_computer^manufacturer=' + acme_corp_SysID.toString() + '^location=' + location_SysID.toString() + '^company=' + company_SysID.toString(); ciName.addEncodedQuery(encodedquery); ciName.query(); while (ciName.next()) { gs.print('cmdb_ci.name ' + ciName.name); } The script now retrieves sys_ids dynamically from system properties instead of embedding them directly in the code. This pattern clears the health scan security flag. 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: ; } } ServiceNow Community: retrieving sys_ids from sys_properties using getProperty