With the use of script, you can enhance or create whole new columns of data in your table map's field mapping.



Procedure 

To use a script in a table field map, follow these steps: 


Access Field Map 

In your ServiceNow instance, go to Perspectium > Control and Configuration > Table Maps. Then, select the desired table map. 

In the PSP Table Field Maps, click the desired field map. 

Add script 

Click the Use Script check box, and a Source Script field will appear. Then, fill the Source Script field. 

Then, click Update


Examples

There are various ways you can use scripting in your field mappings, see below for examples:

Set mapping field value

To set an overall value for your field mapping, use the following: 

answer = ""; 
Conversion to a new format

To script the transformation of an entire record to a new format (ex: convert to a custom JSON format), use the current variable to reference values in the source record and set the answer variable to be the new value returned.

The following example builds a JSON string from the value of correlation_id and short_description in the current record:

var attributes = {"type":"Case"};
var o = {};
o.attributes = attributes;
o.Id = current.correlation_id;
o.Subject = current.short_description.toString();

var j = new JSON();
j = j.encode(o);

answer = j.toString();

For other ways to utilize scripting in your field mappings, contact Perspectium Support.