Service Bridge Transform Current Object?

MattSN
Mega Sage
Mega Sage

Hi Service Bridgers

 

Anyone using the Transforms for Service Bridge know of a way to get the current object or the related task object in a transform?
Feature Reference:

https://www.servicenow.com/docs/csh?topicname=service-bridge-v2-create-transform.html&version=latest

 

I was able to get current.parent.sys_id in a Service Bridge transform but found that it only worked when the record was intitially synced. Aftwards the "current" object was not available in the transform script. Is this expected or documented? Is there a better way? 


@Mike Edmonds of the TMT team?

1 ACCEPTED SOLUTION

If you run JSON.stringify(current) against any table you will get the same result. Here is a snippet from running in a business rule on the incident table.

 

Stringify JSON Current.png

Here are some examples to try running in the Transform.

Note: Parent does not fully exist until after the remote task has been created. Dot-walking to a parent field will not work when a remote task is first synced and could result in an error. Parent will be the sys_id of the sys_id of the parent. You should perform a check such as object_data.parent.number != "" before trying to access dot-walked fields.

 

gs.info('Object Data - Inbound Vars JSON: ' + object_data.inbound_vars_json);

 

gs.info('Object Data - object_data.parent.number: ' + object_data.parent.number);

 

gs.info('Object Data - object_data.parent.assignment_group.description: ' + object_data.parent.assignment_group.description);

 

 

View solution in original post

4 REPLIES 4

Kenny Caldwell
ServiceNow Employee
ServiceNow Employee
object_data contains the remote task which is essentially current in a transform.
 
object_data.parent or object_data.parent.sys_id

Thanks @Kenny Caldwell I have added to the transform a dump of of the object_data object and logged it using JSON.stringify(); It contains the fields but every object is empty. Snippt below:

object_dump {
"sys_meta": null,
"parent": {},
"made_sla": {},
"watch_list": {},
"consumer_connection": {},
"inbound_vars_json": {},
"upon_reject": {},
......

If you run JSON.stringify(current) against any table you will get the same result. Here is a snippet from running in a business rule on the incident table.

 

Stringify JSON Current.png

Here are some examples to try running in the Transform.

Note: Parent does not fully exist until after the remote task has been created. Dot-walking to a parent field will not work when a remote task is first synced and could result in an error. Parent will be the sys_id of the sys_id of the parent. You should perform a check such as object_data.parent.number != "" before trying to access dot-walked fields.

 

gs.info('Object Data - Inbound Vars JSON: ' + object_data.inbound_vars_json);

 

gs.info('Object Data - object_data.parent.number: ' + object_data.parent.number);

 

gs.info('Object Data - object_data.parent.assignment_group.description: ' + object_data.parent.assignment_group.description);

 

 

Thanks @Kenny Caldwell for the reminder on the missing data on the JSON blob of the current object and thanks for sharing your examples. This should be a helpful future reference.