Steps API
The different functions available when configuring Steps.
Basic
executeOutputs()
executeOutputs is the IIFE defined in the Step’s Outputs field.
| Name | Type | Description |
|---|---|---|
| inputs | Record<string, any> | |
| initRecord | GlideRecord | The record that triggered the Integration. |
| step | GlideRecord | The current Step. |
| transaction | GlideRecord | The current Transaction. |
| setOutputs | Function | Sets the outputs that will be used as inputs for the next Step. |
Type
tsfunction executeOutputs( inputs: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setOutputs: (outputs: Record<string, any>) => void ) => voidfunction executeOutputs( inputs: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setOutputs: (outputs: Record<string, any>) => void ) => voidExample
js(function executeOutputs( inputs /*parsed payload from transaction*/, initRecord, step, transaction, setOutputs,) { try { // to set outputs for this step, call setOutputs with an object, or a function that returns an object // if setOutputs is not called, the value that was received as input in this step will be automatically forwarded as outputs // Example with an object setOutputs({ message: 'some text here' }); // Example with a function that returns an object //setOutputs(function(currentInputs) { // return {message: 'some text here'} //}); } catch (e) { return e; } })(JSON.parse(inputs), initRecord, step, transaction, setOutputs);(function executeOutputs( inputs /*parsed payload from transaction*/, initRecord, step, transaction, setOutputs,) { try { // to set outputs for this step, call setOutputs with an object, or a function that returns an object // if setOutputs is not called, the value that was received as input in this step will be automatically forwarded as outputs // Example with an object setOutputs({ message: 'some text here' }); // Example with a function that returns an object //setOutputs(function(currentInputs) { // return {message: 'some text here'} //}); } catch (e) { return e; } })(JSON.parse(inputs), initRecord, step, transaction, setOutputs);
setOutputs()
setOutputs is one of the parameters in executeOutputs. It is used to configure the outputs that will be used as inputs for the next Step of the Integration.
Type
tsfunction setOutputs(outputs: Record<string, any>): void;function setOutputs(outputs: Record<string, any>): void;Example
jssetOutputs({ data: 'For the next step', });setOutputs({ data: 'For the next step', });
onError()
onError is the IIFE defined in the Step’s Error script field.
Type
tsfunction onError( inputs: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, error: string, setRecordData: (params: SetRecordDataParams) => void ) => voidfunction onError( inputs: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, error: string, setRecordData: (params: SetRecordDataParams) => void ) => voidExample
js(function onError(inputs, initRecord, step, transaction, error, setRecordData) { // Example: add the error message to initRecord comments setRecordData({ id: initRecord.getUniqueValue(), table: initRecord.getTableName(), operation: 'update', data: [['comments', 'Hey, an error: ' + error]], }); })(JSON.parse(inputs), initRecord, step, transaction, error, setRecordData);(function onError(inputs, initRecord, step, transaction, error, setRecordData) { // Example: add the error message to initRecord comments setRecordData({ id: initRecord.getUniqueValue(), table: initRecord.getTableName(), operation: 'update', data: [['comments', 'Hey, an error: ' + error]], }); })(JSON.parse(inputs), initRecord, step, transaction, error, setRecordData);
setRecordData()
setRecordData is one of the parameters in onError. It is used to update or create records from the error handler.
Type
tsfunction setRecordData(params: { id: string; table: string; operation: "update"|"insert"; data: [string, string][]; }) => voidfunction setRecordData(params: { id: string; table: string; operation: "update"|"insert"; data: [string, string][]; }) => voidExample
jssetRecordData({ id: '5677b0bb1bd92110c6256575624bcb00', table: 'incident', operation: 'update', data: [['comments', 'Hey, an error: ' + error]], });setRecordData({ id: '5677b0bb1bd92110c6256575624bcb00', table: 'incident', operation: 'update', data: [['comments', 'Hey, an error: ' + error]], });
HTTP
executeRequest()
executeRequest is the IIFE defined in the Step’s Request script.
| Name | Type | Description |
|---|---|---|
| inputs | Record<string, any> | |
| initRecord | GlideRecord | The record that triggered the Integration. |
| step | GlideRecord | The current Step. |
| transaction | GlideRecord | The current Transaction. |
| setRequestData | Function | Configures the HTTP request using dynamic values. |
| setSkipped | Function | Skips the current Step. |
Type
tsfunction executeRequest( inputs: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setRequestData: (params: SetRequestDataParams) => void, setSkipped: () => void ) => voidfunction executeRequest( inputs: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setRequestData: (params: SetRequestDataParams) => void, setSkipped: () => void ) => voidExample
js(function executeRequest( inputs /*parsed payload from transaction*/, initRecord, step, transaction, setRequestData, setSkipped,) { try { setRequestData({ //method: "", // use this to set http method dynamically, overrides "Method" //url: "", // use this to provide a dynamic URL, overrides "Endpoint URL" //headers: {}, // use this to provide dynamic headers, merges with "HTTP headers" body: { test: 'hello', }, //query: {}, }); } catch (e) { return e; } })(JSON.parse(inputs), initRecord, step, transaction, setRequestData, setSkipped);(function executeRequest( inputs /*parsed payload from transaction*/, initRecord, step, transaction, setRequestData, setSkipped,) { try { setRequestData({ //method: "", // use this to set http method dynamically, overrides "Method" //url: "", // use this to provide a dynamic URL, overrides "Endpoint URL" //headers: {}, // use this to provide dynamic headers, merges with "HTTP headers" body: { test: 'hello', }, //query: {}, }); } catch (e) { return e; } })(JSON.parse(inputs), initRecord, step, transaction, setRequestData, setSkipped);
setRequestData()
setRequestData is one of the parameters in executeRequest. It is used to configure the HTTP request.
Type
tsfunction setRequestData(params: { method: 'GET' | 'POST' | 'PATCH' | 'DELETE'; url: string; query: Record<string, string>; headers: Record<string, any>; body: Record<string, any>; }): void;function setRequestData(params: { method: 'GET' | 'POST' | 'PATCH' | 'DELETE'; url: string; query: Record<string, string>; headers: Record<string, any>; body: Record<string, any>; }): void;Example
jssetRequestData({ method: 'POST', // use this to set http method dynamically, overrides "Method" url: 'https://demo-api.devolent.com/api/bounce', // use this to provide a dynamic URL, overrides "Endpoint URL" headers: { // use this to provide dynamic headers, merges with "HTTP headers" 'Content-Type': 'application/json', }, body: { test: 'hello', }, //query: {}, });setRequestData({ method: 'POST', // use this to set http method dynamically, overrides "Method" url: 'https://demo-api.devolent.com/api/bounce', // use this to provide a dynamic URL, overrides "Endpoint URL" headers: { // use this to provide dynamic headers, merges with "HTTP headers" 'Content-Type': 'application/json', }, body: { test: 'hello', }, //query: {}, });
setSkipped()
setSkipped is one of the parameters in executeRequest. It is used to skip the execution of the Step and sets the Transaction's Status to skipped.
Type
tsfunction setSkipped(): void;function setSkipped(): void;Example
jslet someCondition = true; if (someCondition) { setSkipped(); }let someCondition = true; if (someCondition) { setSkipped(); }
executeOutputs()
executeOutputs is the IIFE defined in the HTTP Step's Outputs field. It shares all parameters from the Basic Step, but also includes the response parameter.
| Name | Type | Description |
|---|---|---|
| inputs | Record<string, any> | |
| response | Record<string, any> | The response from the HTTP request. This parameter is only available in HTTP Steps. |
| initRecord | GlideRecord | The record that triggered the Integration. |
| step | GlideRecord | The current Step. |
| transaction | GlideRecord | The current Transaction. |
| setOutputs | Function | Sets the outputs that will be used as inputs for the next Step. |
Type
tsfunction executeOutputs( inputs: Record<string, any>, response: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setOutputs: (outputs: Record<string, any>) => void ) => voidfunction executeOutputs( inputs: Record<string, any>, response: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setOutputs: (outputs: Record<string, any>) => void ) => voidExample
js(function executeOutputs(inputs, response, initRecord, step, transaction, setOutputs) { try { setOutputs({ response }); } catch (e) { return e; } })(JSON.parse(inputs), JSON.parse(response), initRecord, step, transaction, setOutputs);(function executeOutputs(inputs, response, initRecord, step, transaction, setOutputs) { try { setOutputs({ response }); } catch (e) { return e; } })(JSON.parse(inputs), JSON.parse(response), initRecord, step, transaction, setOutputs);
Database
executeDatabaseOperation()
executeDatabaseOperation is the IIFE defined in the Step's Data script.
| Name | Type | Description |
|---|---|---|
| inputs | Record<string, any> | |
| initRecord | GlideRecord | The record that triggered the Integration. |
| step | GlideRecord | The current Step. |
| transaction | GlideRecord | The current Transaction. |
| setRecordData | Function | Defines the fields and values to set on the record. |
| setOutputs | Function | Sets the outputs that will be used as inputs for the next Step. |
| setSkipped | Function | Skips the current Step. |
Type
tsfunction executeDatabaseOperation( inputs: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setRecordData: (params: SetRecordDataParams) => void, setOutputs: (outputs: Record<string, any>) => void, setSkipped: () => void ) => voidfunction executeDatabaseOperation( inputs: Record<string, any>, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setRecordData: (params: SetRecordDataParams) => void, setOutputs: (outputs: Record<string, any>) => void, setSkipped: () => void ) => voidExample
js(function executeDatabaseOperation(inputs /*parsed payload from transaction*/ , initRecord, step, transaction, setRecordData, setOutputs, setSkipped) { try { // Example update: //setRecordData({ // id: initRecord.getUniqueValue(), // data: [ // ['comments', 'Hey, a new comment'] // ] //}); // Example insert: setRecordData({ data: [ ['description', 'Hey, a description!'] ] }); } catch (e) { return e; } })(JSON.parse(inputs), initRecord, step, transaction, setRecordData, setOutputs, setSkipped);(function executeDatabaseOperation(inputs /*parsed payload from transaction*/ , initRecord, step, transaction, setRecordData, setOutputs, setSkipped) { try { // Example update: //setRecordData({ // id: initRecord.getUniqueValue(), // data: [ // ['comments', 'Hey, a new comment'] // ] //}); // Example insert: setRecordData({ data: [ ['description', 'Hey, a description!'] ] }); } catch (e) { return e; } })(JSON.parse(inputs), initRecord, step, transaction, setRecordData, setOutputs, setSkipped);
setRecordData()
setRecordData is one of the parameters in executeDatabaseOperation. It is used to define the fields and values to set on the record.
Type
tsfunction setRecordData(params: { data: [string, string][], sync: boolean, bond?: { create: boolean, externalId: string, internalIdField: string }, id?: string ): void;function setRecordData(params: { data: [string, string][], sync: boolean, bond?: { create: boolean, externalId: string, internalIdField: string }, id?: string ): void;Example
js(function executeDatabaseOperation( inputs /*parsed payload from transaction*/, initRecord, step, transaction, setRecordData, setOutputs, setSkipped, ) { try { // Example update: setRecordData({ id: initRecord.getUniqueValue(), data: [['comments', 'Hey, a new comment']], }); // Example insert: setRecordData({ data: [['description', 'Hey, a description!']], }); } catch (e) { return e; } })(JSON.parse(inputs), initRecord, step, transaction, setRecordData, setOutputs, setSkipped);(function executeDatabaseOperation( inputs /*parsed payload from transaction*/, initRecord, step, transaction, setRecordData, setOutputs, setSkipped, ) { try { // Example update: setRecordData({ id: initRecord.getUniqueValue(), data: [['comments', 'Hey, a new comment']], }); // Example insert: setRecordData({ data: [['description', 'Hey, a description!']], }); } catch (e) { return e; } })(JSON.parse(inputs), initRecord, step, transaction, setRecordData, setOutputs, setSkipped);
setSkipped()
setSkipped is one of the parameters in executeDatabaseOperation. It is used to skip the execution of the Step and sets the Transaction's Status to skipped.
Type
tsfunction setSkipped(): void;function setSkipped(): void;Example
jslet someCondition = true; if (someCondition) { setSkipped(); }let someCondition = true; if (someCondition) { setSkipped(); }
executeOutputs()
executeOutputs is the IIFE defined in the Database Step’s Outputs field. It shares all parameters from the Basic Step, but also includes the getQueryRecord parameter.
| Name | Type | Description |
|---|---|---|
| inputs | Record<string, any> | |
| getQueryRecord | Function | When the operation is query, this function executes the query and returns the GlideRecord. |
| initRecord | GlideRecord | The record that triggered the Integration. |
| step | GlideRecord | The current Step. |
| transaction | GlideRecord | The current Transaction. |
| setOutputs | Function | Sets the outputs that will be used as inputs for the next Step. |
Type
tsfunction executeOutputs( inputs: Record<string, any>, getQueryRecord: () => GlideRecord, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setOutputs: (outputs: Record<string, any>) => void ) => voidfunction executeOutputs( inputs: Record<string, any>, getQueryRecord: () => GlideRecord, initRecord: GlideRecord, step: GlideRecord, transaction: GlideRecord, setOutputs: (outputs: Record<string, any>) => void ) => voidExample
js(function executeOutputs(inputs, getQueryRecord, initRecord, step, transaction, setOutputs) { try { var gr = getQueryRecord(); while (gr.next()) { // get data from the GlideRecord } setOutputs({ response }); } catch (e) { return e; } })(JSON.parse(inputs), getQueryRecord, initRecord, step, transaction, setOutputs);(function executeOutputs(inputs, getQueryRecord, initRecord, step, transaction, setOutputs) { try { var gr = getQueryRecord(); while (gr.next()) { // get data from the GlideRecord } setOutputs({ response }); } catch (e) { return e; } })(JSON.parse(inputs), getQueryRecord, initRecord, step, transaction, setOutputs);