StaticMethods - Global
Static methods are methods that you can use within your server-side Javascripts but aren't a part of any class or API.
You can directly access these methods within a server script without any constructor or other type of instantiation before use.
Static Method - updateVirtualField(GlideRecord remoteTaskGr, String virtualField, String virtualValue, String virtualDisplayValue)
Populates virtual fields in a task table on a target instance when using Service Exchange remote tasks.
A virtual field is a field that exists in a target task table but doesn’t exist in the source task table. You use this method to pass the values for a virtual field from the source instance to the target instance. This method stores the specified values for the virtual field as JSON in the form section of the specified remote task. This remote task is then synced to the target instance where the values are stored in the mapped field in the target task table.
Virtual fields are defined in remote task definitions. Remote task definitions contain inbound and outbound mapping tables that map fields between task tables in source and target instances. When a source table doesn’t contain a field that exists on a target table, the field is configured in the remote task definition as a virtual field. The consumer can then use either Service Exchange transforms or this method to update the values of these virtual fields in the associated target task record.
- The provider creates a remote task definition for the provider Case table and the consumer Incident table.
- On the Inbound fields tab in the Related links of the remote task definition, the provider maps the fields between the Incident table and the Case table.When defining the Affected Instances field, the provider selects the Virtual check box and then selects Affected Instances from the Target field on the Target mapping tab.Note:When defining a virtual field, no source field is defined as it doesn’t exist.
- The provider then publishes the remote task definition, which is synced to the consumer instance.
- The consumer creates a remote task for the Incident table. A JSON payload that holds all values for the mapped fields, including the information on virtual fields, is included on a form section in the remote task.
- The consumer instance calls the updateVirtualField() method, such as in a business rule that runs when records in the Incident table are updated, to set the values of the Affected Instances field in the
remote task.Note:Even though you can populate data in the target table at any time, required fields configured as virtual fields must be populated in the remote task before the remote task is sent to the producer instance.
- The remote task is synced to the provider instance and creates a Case record on the provider instance.
For information on how to create a remote task definition, see Create remote task definitions in Service Exchange for Providers.
For information on how to create a Service Exchange transform, see Transform data with the Service Exchange transform framework.
| Name | Type | Description |
|---|---|---|
| remoteTaskGr | GlideRecord | GlideRecord object of the remote task for which to set the specified virtual field values. |
| virtualField | String | Field name of the virtual field for which to update the associate information. Defined on the Outbound fields related tab of the associated remote task definition. |
| virtualValue | String | Value to set for this field on the target instance. |
| virtualDisplayValue | String | Display value to set for this field on the target instance |
| Type | Description |
|---|---|
| None |
The following example shows how to call this method.
var remoteTaskGr = new GlideRecord("");
/** Remote Task table name,
** Table name vary based on which instance the script is being executed.
**/
remoteTaskGr.get(""); // Remote Task record sys_id
global.sb.updateVirtualField(remoteTaskGr,"<virtual outbound field name>", "<value to set on target field>", "<display value to set on target field>");