UI Policies Not Applying Correctly for Case Variables

KiranLegato
Tera Contributor

Hi Team,

We need to ensure that variables are initialized when a case is created or transferred between services via the agent workspace, similar to how it operates through the ESC portal.

To achieve this, we're using a Business Rule that triggers when the case created in agent workspace and initialize variables belongs to Record producer associated to that service. However, the UI policies do not function as expected, unlike when a case is created in the ESC portal.

For the service "Corrective Action Manager Support", we have four variables. Out of these, three are hidden in the catalog view, and one is hidden in the case view.

Case HRC2291274 was created via the ESC portal, while Case HRC2291279 was created in the agent workspace. Using this Business Rule "InsertVariablesOnCase", we are injecting the variables forcefully. Is there an out-of-the-box feature to retrieve the default variables without using this business rule? Please advise.

In the HR case , you see the extra question "Please provide a detailed description of your support needs" that should not be visible as per the UI policy "Hide Fields in Target Record"

 

As highlighted in the red box in the screenshot, some fields should not be visible per the UI policies "Hide Fields in Catalog" and "Hide Fields in Target Record" specified for the record producers.

 

Our requirement is I want to generate the record producer variables if the case is created through the Agent workspace , those variables should be working as similarly (applying UI policies as well) when you submit the case with record producer from the portal.

 

Now with Business Rule "InsertVariablesOnCase" we are able to see the variables but UI policies are not applying on these variables.

 

Let me know is there any other way we can achieve.

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@KiranLegato 

share the script in that Business rule?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for the responding ,below is the business rule script

(function executeRule(current, previous) {
    var rpSysId = current.hr_service.producer;
    var variableGR = new GlideRecord("item_option_new");
    variableGR.addQuery('cat_item', rpSysId);
    variableGR.orderBy('order');
    variableGR.query();

    while (variableGR.next()) {
        try {
            var qa = new GlideRecord("question_answer");
            var checkEntryOfVar = new GlideRecord("question_answer");
            checkEntryOfVar.addEncodedQuery("table_sys_id=" + current.sys_id + "^question=" + variableGR.sys_id + "^table_name=" + current.getTableName());
            checkEntryOfVar.query();
            if (!checkEntryOfVar.hasNext()) {
                qa.initialize();
                qa.question = variableGR.sys_id;
                qa.question_text = variableGR.question_text;
                qa.order = variableGR.order;
                qa.table_name = current.getTableName();
                qa.table_sys_id = current.sys_id;
                qa.insert();
            }

        } catch (ex) {
            gs.error("Failed to create question_answer for variable: " + variableGR.name + " - " + ex.message);
        }
    }

})(current, previous);

bui

 

@KiranLegato 

so you are doing reverse.

You are associating variables to HR Case using script and keeping the value as empty so that agent can fill.

Did you try debugging the UI policy condition?

Did you try using onChange catalog client script?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

snehareddym
Tera Expert

Please configure the UI Policies using the false condition rather than writing them based on the true condition.

For example, suppose you want to hide the field ‘x’ when the Category is ‘c’.
Instead of writing the condition as Category is ‘c’ → Visible = false for field ‘x’,
write it as Category is not ‘c’ → Visible = true for field ‘x’.