Need to alter Create Case multiselect field mapping in CSM workspace

MelissaS0144719
Tera Contributor

I created a new case type for CSM Workspace. 

I followed the instructions below to enable the Create Case multiselect. 

MelissaS0144719_0-1776435071705.png

There are some fields, like Assignment Group and location that are not mapped OOB from this action. I haven't been able to find the action to modify it or duplicate it to add the fields we need mapped. Has anyone done this before that can point me in the right direction. 
Thanks!

2 REPLIES 2

Naveen20
ServiceNow Employee

The field mappings for the Create Case action with case type selection aren't controlled by the UI Action or a Script Include you'd modify directly. They're driven by a Data Broker Server Script inside UI Builder.

Here's where to go:

Open UI Builder and navigate to the Case Type Multi Select modal page (this is the popup that appears when you click Create Case). Look for the Data Broker Server Script called "Get encoded query to prefill case type form". This script builds the encoded query that prefills the new case record from the source record (e.g., Interaction). You'll find separate script blocks per source table — edit the one matching your source table and add your Assignment Group and Location fields to the encoded query string.

For example, you'd append something like ^assignment_group= + the value from the source record to the existing encoded query being built.

Alternatively, if you want something more upgrade-safe, a Before Insert Business Rule on sn_customerservice_case (set to run on extended tables as well) can populate Assignment Group and Location based on the parent Interaction record after case creation. This avoids touching the OOB UI Builder components entirely.

Thank you for the response!

I would like to make this upgrade safe so I am trying to create a business rule. This is the code that I have so far but it is not mapping the fields when clicking 'Create case'. 

Note- I am trying to get this working on a child table of sn_customerservice_case, and there is no option to 'set to run on extended tables' on the form for the business rule. 

 

Are you able to see anything in the code that I may be missing?

(function executeRule(current, previous /*null when async*/) {

    // Only run on insert
    if (!current.isNewRecord()) {
        return;
    }

    // ---- Find related Interaction via interaction_related_record
    var interactionGR = null;

    var irr = new GlideRecord('interaction_related_record');
    irr.addQuery('document_table', 'sn_customerservice_case');
    irr.addQuery('document_id', current.getUniqueValue());
    irr.orderByDesc('sys_created_on');
    irr.setLimit(1);
    irr.query();

    if (irr.next() && !gs.nil(irr.getValue('interaction'))) {
        interactionGR = new GlideRecord('interaction');
        if (!interactionGR.get(irr.getValue('interaction'))) {
            interactionGR = null;
        }
    }

    // If no interaction → do nothing (case not created from interaction)
    if (!interactionGR) {
        return;
    }

    // ---- COPY FIELDS ----

    // Description
    if (gs.nil(current.description)) {
        if (!gs.nil(interactionGR.description)) {
            current.description = interactionGR.description;
        } else if (!gs.nil(interactionGR.short_description)) {
            current.description = interactionGR.short_description;
        }
    }

    // Assignment Group
    if (gs.nil(current.assignment_group) && !gs.nil(interactionGR.assignment_group)) {
        current.assignment_group = interactionGR.assignment_group;
    }

    // Assigned To
    if (gs.nil(current.assigned_to) && !gs.nil(interactionGR.assigned_to)) {
        current.assigned_to = interactionGR.assigned_to;
    }

    // Location
    if (gs.nil(current.location)) {
        if (!gs.nil(interactionGR.location)) {
            current.location = interactionGR.location;
        } else if (!gs.nil(interactionGR.opened_for)) {
            var u = new GlideRecord('sys_user');
            if (u.get(interactionGR.opened_for) && !gs.nil(u.location)) {
                current.location = u.location;
            }
        }
    }
	
})(current, previous);