Phillip Godwin
ServiceNow Employee

  The Service Bridge Remote Task Definition allows an admin to specify what fields are to be passed back and forth between a connected Provider and Consumer using a Remote Task.  Transforms can be specified that will alter a field value and/or label as it is passed from (outbound transform) and/or to (inbound transform) the Provider or Consumer instances.  An Advanced Transform allows the admin to include a script that will transform the data between the instances as required.

 

Service Bridge provides an object_data.remote_task_vars object that enables the reference and use in a transform script of any of the fields that have been included in the Remote Task Definition.  The purpose of this article is to describe how to reference Remote Task variables from a transform script.

 

I will use a simple example to demonstrate how this can be done.  My Remote Task Definition will trigger a Remote Task on the Consumer instance when an incident is assigned to the “Network Support” group, and the task will flow to the Provider instance and create a corresponding case.  In the Remote Task Definition, I have specified that the inbound Description field will synchronize between the incident and the case on Insert, and I have included the consumer incident Number as an inbound field but have specified that it will Never synch (i.e. it will not be written to a corresponding provider case field).

 

PhillipGodwin_0-1712177339802.png

 

I will use an Advanced Transform to add the customer’s incident number to the provider’s case description so the provider will have an easily visible reference to use in related discussions with the customer.

 

As mentioned above, the specified Remote Task variables can be referenced using the object_data.remote_task_vars object, but I need to know what the related field name for the incident number is so I can use it in my script.  To find a Remote Task variable field name, open the related Remote Task Definition and select the Remote tasks variables related list. 

 

PhillipGodwin_1-1712177339813.png

 

I can see that the field name for the inbound incident number is: number50270d9ec31c8210075c35aa05013126.

 

Now I can create an Advanced Transform with a script that uses the number field to transform the provider case description.

 

PhillipGodwin_2-1712177339819.png

 

See that the script adds the customer’s incident number to the case description by referring to the number field in the remote task variables object:

 

PhillipGodwin_3-1712177339822.png

 

And see the result…

 

PhillipGodwin_4-1712177339827.png

 

 

I hope this article helps you better understand how you can pass fields using Service Bridge Remote Tasks and then use them in your Transform scripts!

Comments
Community Alums

Really useful tip, thanks Phillip

Tera Contributor

 

Removed Question. Thanks for the KB!

ServiceNow Employee
ServiceNow Employee

Hi - My guess is that you've activated a new revision of the remote task since the transform was created and the service_offering variable name changed.  After the Xanadu store release, when you create a new revision of a remote task definition it creates an entirely new version and the variable names in object_data.remote_task_var will change. 

 

...phil

Mega Sage

@Phillip Godwin Thank you for the clarity on the object_data.remote_task_var change between versions. If I understand correctly, this means that any time you update your task definition, (for example to add a new field), you have update all transforms associated to the definition, on any field that uses the object_data.remote_task_var.

 

This seems like a regression. Is this accurate? Is there a better option?

ServiceNow Employee
ServiceNow Employee

Hi @MattSN - this is being fixed in the August store release (taking the sys_id out of the variable name).

 

...phil

Tera Contributor

Excellent news! Thanks @Phillip Godwin we appreciate the communication from your product team in these channels.

Tera Contributor

@Phillip Godwin This seems really useful, but one thing I feel like I am seeing is that the values of the variables in object_data.remote_task_vars are the values on the remote task before the transforms are run.

So equivalent to previous. We have a use case a partner wants where when we Resolved our Case it updates their incident's Resolution code to a specific value on their side. But only when our Case changes to the Resolved state.

 

On inbound  transforms we aren't able to figure out how to access the state variable's inbound value within the resolution code transform to build that logic. The object_data.remote_task_vars.state value would show the old value and not the new intended value sent to the consumer side at the time of transform.

 

Is this even possible with the current transform capabilities or would you have to handle in some other way as a secondary update to the parent task (incident in this case) with a flow or after BR on the remote task table?

ServiceNow Employee
ServiceNow Employee

@Michael Ramos here is an example you can use in a Consumer Inbound Transform to conditionally set the Resolution Code based on incoming State value.

 

This is just an example and you will need to account for more conditions to prevent undesired outcomes.

 

Note: In "inboundVarsJSON.state.value" - replace the "state" name with what is being used for the Inbound Field - Field name for State coming from the Provider in the Remote Task Definition.

 

Screenshot 2025-09-17 at 2.50.57 PM.png

Tera Contributor

@Kenny Caldwell Thanks! I actually ended up doing something similar to this.

 

Since output.value sets the value on the parent Task and we don't want to overwrite it unless the conditions are set, we can dot walk object_data.parent to get the current value on the parent and then set the output.value to the current value on parent task and then if the condition is met then update it accordingly.

 

So like this. 

 

output.value  = '';
output.label = input.label;

var parent = object_data.parent.getRefRecord();
if (parent.isValidRecord()) {
    output.value = parent.getValue('close_code');
    var inboundVarJSON = JSON.parse(object_data.inbound_vars_json);
    if (inboundVarsJSON.state.value = '6') {
        output.value = '6';
    }
} 

 

I set output.label to the input.label regardless so when we view the Remote Task its easy to see the value sent in the inbound field variables and output.label only seems to sets the variable in object_data.remote_task_vars. 

ServiceNow Employee
ServiceNow Employee

@Michael Ramos that works. Exactly right about output.label vs output.value. The output.label gets displayed in the Inbound fields on the remote task form and the output.value gets written to the parent record field for the mapping.

 

The output.label also goes into the worknotes of the parent record in the field update summarization. The summarization displays the Field: Value being updated on the parent record. Field is the parent record field and Value is the output.label. In my screenshot Resolution code had an output.label = "Actually Empty" with an output.value = "". Resolution code in the parent record updated to blank.

 

My only concern would be that this may confuse someone if they are comparing worknotes to field values as the Resolution code field value was blank while the worknote shows that it should be "Actually Empty". The incoming values are in the Inbound vars json field of the remote task.

 

Worknotes Field Summarization.png

 

Tera Contributor

@Kenny Caldwell that is a fair point on the Work notes potentially causing confusion. Similar to if you had an Inbound field label named something other than the field it is being transformed into.

 

In that case probably best to set output.label to the matching label that will be displayed on the parent record. 

 

What would you recommend as an efficient way to get that label since as time goes on a choice's label may change?

 

If its a reference field then using GlideRecord to get the record you are transforming to is easy enough to get the display value but how about for choice fields? Querying sys_choice?