<h2>Variables are becoming Editable on HR service change.</h2><br/><div style="overflow-x:auto"><article><div ><h2 >Issue </h2><section><div class="ns-kb-css-body-editor-container"> <ul><li>On HR cases created through a Record Producer, catalog variables become editable or lose their mandatory behavior after the HR service or case class changes.</li><li>Catalog UI Policies and Client Scripts from the Record Producer are not applied on the HR case form.</li></ul> <span id="ns-kb-css-end-div-identifier" style="display: none; pointer-events: none;"></span></div></section></div><div ><h2 >Symptoms</h2><section><div class="ns-kb-css-body-editor-container"> <ul><li>Variables that are mandatory on the original <strong>sn_hr_core_case</strong> record are not mandatory after the case moves to a COE table such as <strong>sn_hr_core_case_talent_management</strong>.</li><li>Read-only variables become editable after the HR service changes.</li><li>The catalog UI Policy does not load on the affected form. A console.log added to the UI Policy script does not fire.</li><li>No error message is shown. The failure is silent.</li></ul> <span id="ns-kb-css-end-div-identifier" style="display: none; pointer-events: none;"></span></div></section></div><div ><h2 >Facts</h2><section><div class="ns-kb-css-body-editor-container"> <ul><li>The HR case variable formatter (OOB UI macro) looks up the case in <strong>sc_item_produced_record</strong> to find the Record Producer, then applies its UI Policies and Client Scripts.</li><li>Variables are stored in <strong>question_answer</strong> and linked to the case through <strong>sc_item_produced_record</strong>.</li><li>The business rule <strong>Predict COE, Service after insert</strong> on <strong>sn_hr_core_case</strong> is designed for the inbound email flow, not Record Producer submissions.</li><li>If a customisation or AI agent changes <strong>sys_class_name</strong> or the HR service, the Record Producer references can fall out of sync with the new case class.</li><li>Changing <strong>sys_class_name</strong> on a Record Producer case is not a supported out-of-box flow.</li></ul> <span id="ns-kb-css-end-div-identifier" style="display: none; pointer-events: none;"></span></div></section></div><div ><h2 >Release</h2><section><div class="ns-kb-css-body-editor-container"> <ul><li>Zurich (observed on Patch 11)</li><li>Australia (observed on Patch 6)</li></ul> <span id="ns-kb-css-end-div-identifier" style="display: none; pointer-events: none;"></span></div></section></div><div ><h2 >Cause</h2><section><div class="ns-kb-css-body-editor-container"> <ul><li>A customised business rule changes <strong>sys_class_name</strong> at insert, and an AI agent later changes the <strong>hr_service</strong>.</li><li>After this, the Record Producer references no longer match the case: <ul><li><strong>sc_item_produced_record.record_key</strong> was empty (null) on the affected record.</li><li><strong>sc_item_produced_record.record_table</strong> and <strong>question_answer.table_name</strong> did not match the current case class.</li></ul> </li><li>Without a complete link, the variable formatter cannot load the Record Producer UI Policies and Client Scripts, so variables lose their mandatory and read-only behavior.</li></ul> <span id="ns-kb-css-end-div-identifier" style="display: none; pointer-events: none;"></span></div></section></div><div ><h2 >Resolution</h2><section><div class="ns-kb-css-body-editor-container"> <ul><li>For the variable editor and UI Policies to work on a task record, the following values must be correct: <ul><li><strong>sc_item_produced_record.record_key</strong> = sys_id of the HR case created by the Record Producer</li><li><strong>sc_item_produced_record.record_table</strong> = current HR case table name (for example <strong>sn_hr_core_case_talent_management</strong>)</li><li><strong>question_answer.table_name</strong> = current HR case table name</li></ul> </li><li>To verify: <ul><li>Open the <strong>sc_item_produced_record</strong> list and filter by the case number in the <strong>Task</strong> field.</li><li>Confirm <strong>record_key</strong> and <strong>record_table</strong> are populated and correct.</li><li>Open the <strong>question_answer</strong> list, filter by <strong>table_sys_id</strong> = case sys_id, and confirm <strong>table_name</strong> matches the case class.</li></ul> </li><li>Correct any mismatched or empty values. Fixing these values restored the variable behavior in testing.</li><li>To keep the values aligned after every class or service change, create an after Insert and Update business rule on <strong>sn_hr_core_case</strong>: <ul><li>Advanced: checked</li><li>Run asynchronously: yes, so the Record Producer has already written its rows</li><li>Condition: <code>current.operation() == 'insert' || current.sys_class_name.changes()</code></li></ul> </li><li>Sample script (guidance only, not an out-of-box or supported fix; review and test in sub-production first):</li></ul> <pre><code>(function executeRule(current, previous) { var caseId = current.getUniqueValue(); var targetClass = current.getValue('sys_class_name'); var qa = new GlideRecord('question_answer'); qa.addQuery('table_sys_id', caseId); qa.addQuery('table_name', '!=', targetClass); qa.query(); while (qa.next()) { qa.setValue('table_name', targetClass); qa.setWorkflow(false); qa.update(); } var pr = new GlideRecord('sc_item_produced_record'); var cond = pr.addQuery('record_key', caseId); cond.addOrCondition('task', caseId); pr.query(); while (pr.next()) { pr.setValue('record_key', caseId); pr.setValue('record_table', targetClass); pr.setWorkflow(false); pr.update(); } })(current, previous);</code></pre> <ul><li>Maintaining and supporting any custom script remains with the customer's platform team.</li></ul> <span id="ns-kb-css-end-div-identifier" style="display: none; pointer-events: none;"></span></div></section></div><div ><h2 >Related Links</h2><section><div class="ns-kb-css-body-editor-container"> <ul><li><a href="https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0863000">KB0863000</a></li><li><a href="https://www.servicenow.com/community/developer-forum/ui-policies-not-applying-correctly-for-case-variables/m-p/3424855">Community: UI Policies not applying correctly for case variables</a></li></ul> <span id="ns-kb-css-end-div-identifier" style="display: none; pointer-events: none;"></span></div></section></div></article></div>