ServiceNow Service Bridge integration Mapping of the Reference field (Assignment Group)

SaiprasannaA
Tera Contributor

I have established the connection using Service Bridge Between two ServiceNow instances and did the incident integration with service bridge remote task definition. For the incident all the fields are mapping except reference fields(for example Assignment group field).

In the provider instance i have group - Demo Group, The same group i have created in the Consumer instance as well, When i created incident from provider instance, the incident got created in the consumer instance, but the assignment group is not mapping.

 

But we can seen the assignment group has been sent to consumer instance(in remote task of the incident the assignment group is populated but not on the incident form).

 

For this i have written an advanced transform to map the display value of the assignment group, but still the assignment group is not mapping. below is the script I'm using.

 

output.label = input.label;

if(direction == 'outbound'){
var ag = new GlideRecord('sys_user_group');

    //if (ag.get(input.value)) {
    if(ag.get(input.label)){
        var grp = ag.getDisplayValue();
        output.label = grp;
        gs.info("AG " + output.label);
        gs.info("Group " + grp);     
    }
}
 
SaiprasannaA_0-1745844192165.png

 

1 ACCEPTED SOLUTION

Kenny Caldwell
ServiceNow Employee
ServiceNow Employee

On the remote task in the consumer instance, the Inbound field Assignment Group shows the display value of the group. These Inbound fields are string fields so they can only show one value which is the display value not the value. There is a field which is not on the form called Inbound vars json. This field contains the values and display values of the Inbound fields. You don't need to interact with it directly. The field mappings and transforms will handle this interaction for you.

 

Your group name is in the Inbound field - Assignment Group. The sys_id of the group is in the Inbound var json. When Service Bridge is writing data to the Incident, it is looking at the value of Assignment Group in the Inbound vars JSON field. This value is the sys_id of the assignment group in the provider instance.

 

Looking at the screenshot you provided you can see the icon with circle around the i but no value in the reference field. This is because the reference field is holding a sys_id it does not recognize so it displays blank. The value of the assignment group did make it to the Incident but that assignment group sys_id does not exist.

post screen shot.png

So you need to create an Inbound Transform to get the correct value before the incident gets updated. You started to create an Inbound Transform but the Information message got you. The message does not pertain to your situation. It has to do with tables and fields in the provider which are not present in the consumer. In this case the Incident table and assignment group field are in both the provider and consumer instances.

 

Here is an example Inbound transform. I added an else for a default value but not required. output.value and output.label should have a value.

 

Consumer Transform.png

 

 

 

View solution in original post

15 REPLIES 15

Hello

Yes i have tried the way you suggested now in the logs i can see the values but still, at the consumer instance on the incident form the assignment group is not populated.
Here is my code

 

/*
 ** The 'input' object contains the original value and label
 ** 'direction' contains an 'inbound' or 'outbound' value to determine transform direction
 ** 'object_data' contains the Remote Task GlideRecord
 ** It is required to set the variables 'output.value' and 'output.label' with your script.
 */
var group = input.value;
gs.info("Group name is " + group);
if(direction == 'outbound'){
    var ag = new GlideRecord('sys_user_group');
    ag.addQuery('sys_id', group);
    ag.query();
    if(ag.next()){
        output.label = ag.getDisplayValue();
        output.value = group;
        gs.info("Group name after " + output.label);
    }
}

Kenny Caldwell
ServiceNow Employee
ServiceNow Employee

Looks like you are conditioning out the script. In your transform you have - if (direction == 'outbound'){ but this is inbound from the provider. Are you trying to run this both Inbound and Outbound? In the transform you can just specify Inbound.

Hello Kenny,

 

I'm not running this on both sides. 
i have written this transform only in the provider instance, so when incident created from the provider to consumer, the group should reflect in the consumer instance.

So i considered this as an outbound from provider to consumer. Is that correct. Or what exactly condition should be when it from provider to consumer ?

If the transform is running in the Provider then it is Outbound to the Consumer.

 

Looking at the script:

1. input.label here " if(ag.get(input.label)){ " is the name of the group "Demo Group"

2. The next line "var grp = ag.getDisplayValue();" you are getting the display value but really you already have it..."Demo Group".

3. The next line "output.label = grp;" you set output.label to the display value. You should also be setting the output.value.

 

Things to do/change:

1. You already have the display value of the group. You don't need a transform to get it.

2. You are only setting the output.label. You should be setting the output.value as well. The consumer instance will use output.value in the mapping.

3. You are sending the display value to the consumer. In the consumer you will need an Inbound transform to find the group Demo Group and set output.value of the inbound transform to the sys_id of Demo Group.

Now i can see i am sending the assignment group name, here the incident is connected between provider & consumer instance with Remote task, Like when i can create an incident in the provider instance , it will generate a remote task and the same remote task will be connected to consumer instance and that will create the incident in the consumer instance.

Here when i create incident in provider and sending it to consumer, the incident is created, but the assignment is showing up in the remote task but not on the incident.

This is the incident i have created in my provider instance
provider1.png

The same connected to consumer. this is consumer remote task , here in the remote task Group is shown, which i have sent from the provider.
consumer task.png

but on incident the group is not showing up (consumer incident)

SaiprasannaA_0-1746086850518.png



AS you suggested to write the inbound transform at consumer end to accept the provider reference field value. But when i tried it is nit working and also here in the consumer side the transform info states different meaning. Could you please help in understanding this and help in fixing it.

 

Inbound transform at consumer instance

SaiprasannaA_1-1746086995303.png