Loading...
Loading...
When trying to use the Compare with latest template function in standard change proposals of 'Modify an existing template' Proposal type, if the value of a custom Change Request field is set to "--none--", the diff function breaks. Steps to Reproduce 01) Navigate to sys_dictionary.list and create a new record: Table: change_request Type: String Column label: U String Field Column name: u_string_field Max length: 40 Choice List Specification > Choice: Dropdown with -- None -- 02) Navigate to std_change_record_producer.list and open 'Reboot Windows Server' (or any other Template name) 03) Under Related Links, click on 'Modify Template' Template description : test Change Request values > Assignment Group : Change Management Change Request values > Justification : test Change Request values > Risk and impact analysis : test Change Request values > U String Field : -- None -- Then click 'Save' at the bottom right 04) After page reloads, under Related Links, click on 'Compare with latest template' EXPECTED: Compare with latest template should be able to compare changes ACTUAL: Compare with latest template breaks with the following error: TypeError: Cannot convert null to an object. (sys_script_include.871fb6060a0a0bb000fc0c937940583d.script; line81)
Within the StdChangeUtils Script Include, add the following function to the script to override the _getDisplayValueFromGlideRecord function: _getDisplayValueFromGlideRecord: function(name, queryNameLabels, queryNameValues, sampleChangeGr) { var displayValue = ""; var fieldName; var fieldValue; var queryCtr = -1; for (var i = 0; i < queryNameLabels.length; i++) if (queryNameLabels[i].name === name) queryCtr = i; if (queryCtr >= 0) { fieldName = queryNameValues.names[queryCtr]; fieldValue = queryNameValues.vals[queryCtr]; if (fieldValue.startsWith('javascript:')) { var scriptEvaluator = new GlideScriptEvaluator(); scriptEvaluator.setEnforceSecurity(true); fieldValue = scriptEvaluator.evaluateString(fieldValue, false) + ""; } if (queryNameLabels[queryCtr].valid) { sampleChangeGr.setValue(fieldName, fieldValue); displayValue = sampleChangeGr.getDisplayValue(fieldName); } else displayValue = fieldValue; } // The Differ that ends up using these values dies spectacularly when given a null value to diff if (typeof displayValue === "undefined" || displayValue == null) return ""; return displayValue; }, The bold section of code is the change that prevents this problem from occurring.
PRB1526094
Click on a version to see all relevant bugs
ServiceNow Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.