Skip to content

Instantly share code, notes, and snippets.

@icerge
Last active December 6, 2023 11:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save icerge/e1ab659ee255d12dd73a0f1c8890df3c to your computer and use it in GitHub Desktop.
Save icerge/e1ab659ee255d12dd73a0f1c8890df3c to your computer and use it in GitHub Desktop.
REST API things

Import Set API

Custom response

For any good reason I need to get more things in my Import Set response for REST interface. Ok, I just go to Transform map, use Explicit script, that script right in the transform map record, type there:

response.custom_element = "Welcome, REST response extension!";

and enJoy the Rest of the day! :)

Note, credits go to SN community. Stay brave!

Technical proof of the concept (there was no Rest some time ago)

The REST API comes to the stage

Note: The status_message and error_message fields on transformation scripts are processed and returned in response, along with any custom response fields.

Automate import from data source and transformation

// Load data from data source
var loader = new GlideImportSetLoader();
var importSetGr = loader.getImportSetGr(dataSource);
loader.loadImportSetTable(importSetRec, dataSource);
importSetGr.state = "loaded";
importSetGr.update();
		
// Run transformation
var transformWorker = new GlideImportSetTransformerWorker(importSetRec.sys_id, transformMapIDs);
transformWorker.setBackground(true);
transformWorker.start();

Credits: SN communite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment