ServiceNow Service Bridge Integration. Assignment Group mapping issue

SaiprasannaA
Tera Contributor

I Have integrated two servicenow instance using service bridge. created groups with same name in two instances as Demo Group, as i created so the sys id's will be different in two instance but the name will be same, So I'm writing a advanced transform to map the assignment group.

Incident is created from consumer and synced with provider instance, but the group is not mapping in provider instance assignment group field, and even the logs are not coming.

 

The pasted image is from provider instance.

roviderTransform.png

 

 

1 REPLY 1

Itallo Brandão
Giga Guru

Hi Saiprasanna,

I can see the issue directly in your screenshot. The logs are not generating because the Transform is currently configured to never run for incoming data.

The Root Cause: You mentioned the Incident is created on the Consumer and synced to the Provider. For the Provider instance, this is an Inbound transaction.

  1. Checkbox: In your screenshot, the "Inbound" checkbox is unchecked. This means the Service Bridge completely skips this transform when receiving data.

  2. Script Logic: Your code explicitly checks if (direction == 'outbound'). Since the creation event is 'inbound', this if block returns false immediately, and the code inside (including gs.info) never executes.

How to Fix It:

  1. Update the Configuration:

    • Check the Inbound box at the top of the form.

  2. Update the Script: You need to handle the Inbound logic (Map Name -> SysID). Update your code to look like this:

(function(input, output, direction) {

    // LOGIC FOR INCOMING DATA (Consumer -> Provider)
    // We receive a Name string and need to find the local Group SysID
    if (direction == 'inbound') {
        
        // Usually, the string name comes in 'input.display_value' or just 'input' depending on the sender setup. 
        // Let's try to grab the name safely.
        var groupName = input.display_value || input.value || input; 
        
        gs.info("Service Bridge Transform: Searching for group named: " + groupName);

        if (groupName) {
            var ag = new GlideRecord('sys_user_group');
            ag.addQuery('name', groupName);
            ag.setLimit(1); // Good practice
            ag.query();

            if (ag.next()) {
                output.value = ag.getUniqueValue(); // Set the local SysID
                gs.info("Service Bridge Transform: Found group SysID: " + output.value);
            } else {
                gs.warn("Service Bridge Transform: No local group found with name: " + groupName);
            }
        }
    }

    // LOGIC FOR OUTGOING DATA (Provider -> Consumer)
    // We have a SysID and want to send the Name string
    else if (direction == 'outbound') {
        // If the fields are mapped correctly, the system might handle SysID->DisplayValue automatically.
        // If not, you would convert the local SysID to a Name here.
    }

})(input, output, direction);

Key Takeaway: Since you are creating the ticket on the Consumer side, the Provider needs an Inbound transform to translate the incoming string "Demo Group" into the local matching SysID.

If this response helps you solve the issue, please mark it as Accepted Solution.
This helps the community grow and assists others in finding valid answers faster.

Best regards,
Brandão.