Skip to content

Steps API

The different functions available when configuring Steps.

Basic

executeOutputs()

executeOutputs is the IIFE defined in the Step’s Outputs field.

NameTypeDescription
inputsRecord<string, any>
initRecordGlideRecordThe record that triggered the Integration.
stepGlideRecordThe current Step.
transactionGlideRecordThe current Transaction.
setOutputsFunctionSets the outputs that will be used as inputs for the next Step.
  • Type

    ts
    function executeOutputs(
    	inputs: Record<string, any>,
    	initRecord: GlideRecord,
    	step: GlideRecord,
    	transaction: GlideRecord,
    	setOutputs: (outputs: Record<string, any>) => void
    ) => void
    function executeOutputs(
    	inputs: Record<string, any>,
    	initRecord: GlideRecord,
    	step: GlideRecord,
    	transaction: GlideRecord,
    	setOutputs: (outputs: Record<string, any>) => void
    ) => void
  • Example

    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

    ts
    function setOutputs(outputs: Record<string, any>): void;
    function setOutputs(outputs: Record<string, any>): void;
  • Example

    js
    setOutputs({
      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

    ts
    function onError(
    	inputs: Record<string, any>,
    	initRecord: GlideRecord,
    	step: GlideRecord,
    	transaction: GlideRecord,
    	error: string,
    	setRecordData: (params: SetRecordDataParams) => void
    ) => void
    function onError(
    	inputs: Record<string, any>,
    	initRecord: GlideRecord,
    	step: GlideRecord,
    	transaction: GlideRecord,
    	error: string,
    	setRecordData: (params: SetRecordDataParams) => void
    ) => void
  • Example

    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

    ts
    function setRecordData(params: {
    		id: string;
    		table: string;
    		operation: "update"|"insert";
    		data: [string, string][];
    	}) => void
    function setRecordData(params: {
    		id: string;
    		table: string;
    		operation: "update"|"insert";
    		data: [string, string][];
    	}) => void
  • Example

    js
    setRecordData({
      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.

NameTypeDescription
inputsRecord<string, any>
initRecordGlideRecordThe record that triggered the Integration.
stepGlideRecordThe current Step.
transactionGlideRecordThe current Transaction.
setRequestDataFunctionConfigures the HTTP request using dynamic values.
setSkippedFunctionSkips the current Step.
  • Type

    ts
    function executeRequest(
    	inputs: Record<string, any>,
    	initRecord: GlideRecord,
    	step: GlideRecord,
    	transaction: GlideRecord,
    	setRequestData: (params: SetRequestDataParams) => void,
    	setSkipped: () => void
    ) => void
    function executeRequest(
    	inputs: Record<string, any>,
    	initRecord: GlideRecord,
    	step: GlideRecord,
    	transaction: GlideRecord,
    	setRequestData: (params: SetRequestDataParams) => void,
    	setSkipped: () => void
    ) => void
  • Example

    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

    ts
    function 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

    js
    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: {},
    });
    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

    ts
    function setSkipped(): void;
    function setSkipped(): void;
  • Example

    js
    let 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.

NameTypeDescription
inputsRecord<string, any>
responseRecord<string, any>The response from the HTTP request. This parameter is only available in HTTP Steps.
initRecordGlideRecordThe record that triggered the Integration.
stepGlideRecordThe current Step.
transactionGlideRecordThe current Transaction.
setOutputsFunctionSets the outputs that will be used as inputs for the next Step.
  • Type

    ts
    function executeOutputs(
      inputs: Record<string, any>,
      response: Record<string, any>,
      initRecord: GlideRecord,
      step: GlideRecord,
      transaction: GlideRecord,
      setOutputs: (outputs: Record<string, any>) => void
    ) => void
    function executeOutputs(
      inputs: Record<string, any>,
      response: Record<string, any>,
      initRecord: GlideRecord,
      step: GlideRecord,
      transaction: GlideRecord,
      setOutputs: (outputs: Record<string, any>) => void
    ) => void
  • Example

    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.

NameTypeDescription
inputsRecord<string, any>
initRecordGlideRecordThe record that triggered the Integration.
stepGlideRecordThe current Step.
transactionGlideRecordThe current Transaction.
setRecordDataFunctionDefines the fields and values to set on the record.
setOutputsFunctionSets the outputs that will be used as inputs for the next Step.
setSkippedFunctionSkips the current Step.
  • Type

    ts
    function executeDatabaseOperation(
      inputs: Record<string, any>,
      initRecord: GlideRecord,
      step: GlideRecord,
      transaction: GlideRecord,
      setRecordData: (params: SetRecordDataParams) => void,
      setOutputs: (outputs: Record<string, any>) => void,
      setSkipped: () => void
    ) => void
    function executeDatabaseOperation(
      inputs: Record<string, any>,
      initRecord: GlideRecord,
      step: GlideRecord,
      transaction: GlideRecord,
      setRecordData: (params: SetRecordDataParams) => void,
      setOutputs: (outputs: Record<string, any>) => void,
      setSkipped: () => void
    ) => 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);

setRecordData()

setRecordData is one of the parameters in executeDatabaseOperation. It is used to define the fields and values to set on the record.

  • Type

    ts
    function 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

    ts
    function setSkipped(): void;
    function setSkipped(): void;
  • Example

    js
    let 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.

NameTypeDescription
inputsRecord<string, any>
getQueryRecordFunctionWhen the operation is query, this function executes the query and returns the GlideRecord.
initRecordGlideRecordThe record that triggered the Integration.
stepGlideRecordThe current Step.
transactionGlideRecordThe current Transaction.
setOutputsFunctionSets the outputs that will be used as inputs for the next Step.
  • Type

    ts
    function executeOutputs(
      inputs: Record<string, any>,
      getQueryRecord: () => GlideRecord,
      initRecord: GlideRecord,
      step: GlideRecord,
      transaction: GlideRecord,
      setOutputs: (outputs: Record<string, any>) => void
    ) => void
    function executeOutputs(
      inputs: Record<string, any>,
      getQueryRecord: () => GlideRecord,
      initRecord: GlideRecord,
      step: GlideRecord,
      transaction: GlideRecord,
      setOutputs: (outputs: Record<string, any>) => void
    ) => void
  • Example

    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);