top of page
Search

HOOKS IN CELIGO

Hooks are custom code that can run at different stages during the execution of a flow to modify the behaviour of export and import processes. You use different types of hooks at each step of the integration process to perform advanced functions.



Import hooks

A flow in integrator.io consists of a source (export from an app, database, or a webhook listener) and a destination (import, file transfer, or lookup). In simple terms, an export retrieves data of the source application and breaks it into smaller pages. An processes those pages and stores the data in the destination application.


NOTE: Hooks typically modify the JSON records in your flow’s data, including any records parsed from a file exported from a server or uploaded in the Data Loader.

postResponseMap hook

postResponseMap hook runs immediately after response mappings and regular mappings. Use this hook to process records after response mapping before they are passed in your flow.

Any changes that you made to record with the postResponseMap hook will affect all downstream applications. You do not need to define a response mapping to use this hook. You also use this hook instead to perform the same logic.

Common use cases:

  • Error Management: Ignore errors, trigger errors, modify error messages

  • Data Logging: Use script logs to the record data and events

  • Data Processing: To Perform calculations and transformations on the raw data should be returned by the endpoint.

postResponseMap hook options argument fields

The function will pass one ‘options’ argument that has the following fields.

Field nameDescriptionpreMapDataArray of records represent the page of data before it was mapped. A record can be object {} or array [] depending on the data source.postMapDataArray of records represent the page of data after it was mapped. Record can be an object {} or array [] depending on the data source.responseDataAn array of response the page of data that was submitted to the import application. An individual response will have the following fields:

Pre map hook

Hooks get invoked before the fields are mapped to their respective fields in the objects to be imported. The premap hook can be used to reformat the record's fields before they get mapped.

You use this hook to apply logic to the data within an import prior to going through the mapping process. Any manipulation of data in this step only apply to the import that it is running on.

Common use cases:

  • Insert default values

  • Format data needed for mapping

preMapFunction: The name of the function can be changed to anything you like.The function will be passed an 'options' argument and a callback argument.

Pre map hook options argument fields

The first argument 'options' has the following structure:

{

"bearerToken":"",

"_importId":"",

"_connectionId":"",

"_integrationId":"",

"_flowId":"",

"data":[],

"settings":{},

"configuration":{}

}

Post map hook

Post map hook gets invoked after the fields in the source objects have been mapped to their respective fields in the object to be imported. It can be used to further modify the mapped data.

Post map hooks run on the mapped data in the import before it is submitted to the target system.

Common use cases:

  • Set default values based on mapped data

  • Run complex calculations

postMapFunction: The name of the function can be changed to anything you like.

The above function will be passed an 'options' argument and a callback argument.

Post map hook options argument fields

The first argument 'options' has the following structure:

{

"bearerToken":"",

"_importId":"",

"_connectionId":"",

"_integrationId":"",

"_flowId":"",

"preMapData":[],

"postMapData":[],

"settings":{},

"configuration":{}

}

Post submit hook

Post submit hook gets invoked after the records are processed by the import. You can use this to further process imported objects and modify the response data received from import for success and error cases. Post submit can also be used to invoke some other process which needs to be done at the end of the import.

Post submit hooks run after the record has been successfully synced to the target system, and prior to the flow moving on to the next step of the integration.

Common use cases:

  • Format the response to be use in your response mapping

  • Validate the response from the target system

  • Provide details around error messages

postSubmitFunction: The function name can be changed to anything you like.

Post submit hook options argument fields

The first argument 'options' has the following structure:

{

"bearerToken":"",

"_importId":"",

"_connectionId":"",

"_integrationId":"",

"_flowId":"",

"preMapData":[],

"postMapData":[],

"responseData":[],

"settings":{},

"configuration":{}

}

postAggregate hook

postAggregate hook gets invoked after the final aggregated file is uploaded to the destination service.

Note : The postAggregate hook only works when the 'skipAggregation' property is 'false'. This hook is passed a read only object.

postAggregrateFunction: The function name can be changed to anything you like.

postAggregate hook options fields

The first argument 'options' has the following structure:

{

"bearerToken":"",

"_importId":"",

"_connectionId":"",

"_integrationId":"",

"_flowId":"",

"postAggregateData":{},

"settings":{},

"configuration":{}

}

Export hooks

Hooks are custom code that can run at different stages during the execution of a flow to modify the behaviour of export and import processes. We can use different types of hooks at each step of the integration process to perform advanced functions.

The below table lists the script formats available for each export hook type:

Hook typeJavaScriptStackSuiteScript 1.0SuiteScript 2.0preSend xxpreSavexx

Hook types

  • Script – integrator.io manages and executes your code

  • Stack – Your own server or AWS lambda hosts your code

preSave hook

You can use a preSave hook to format, filter, and perform logic on the data coming from your export before it moves on to the rest of your data flow. Logic that applies to the data in all steps of the integration should be done at this stage of the flow, the following typical requirements:

  • Filter out data at a line level

  • Complex the data formatting (turn comma-separated text into an array)

  • Perform the data validation

The Pre save hook is invoked after the export a page is complete but before the page is sent to the destination application (import or lookup) for processing. You can use this hook to add or delete records or modify the existing records present in the data.

Options argument fields

The first argument (options) has the following fields:

Field NameDescriptionbearerTokenA one-time bearer token can be used to invoke selected integrator.io API routes.previewThe Boolean flag used to indicate that this export is being used by the integrator.io UI to get the sample of the data being exported.dataAn individual record can be an object {}, or an array [] depending on the data source.errorsAn array of the errors where each error has the following structure: { code: '', message: '', source: '' }_exportIdThe _exportId currently running._connectionIdThe _connectionId currently running._flowIdThe _flowId currently running._integrationIdThe _integrationId is currently running.pageIndex0 based. context is the batch export currently running. These are sent to Pre save hooks so that developers know which page is being processed.lastExportDateTimeThis variable is sent to PreSave hooks for the delta flows so that developers can programmatically exclude records using these dynamic date values.currentExportDateTimeVariables are sent to Pre save hooks for delta flows so that developers can programmatically exclude records using these dynamic date values.configurationAn optional configuration object that can be set directly on the export resource (to further customise the hooks behaviour).

Callback arguments

The function can use the following callback arguments:

Argument NameDescriptionerrAn error object to signal fatal exceptions and will stop the flow.responseDataAn object that has the following structure: { "data":[], "errors":[{ "code":"", "message":"", "source":"" }], "abort":"true|false" }dataYour modified data.errorsYour modified errors.abortInstruct the batch export currently running to stop and generating new pages of data. module.hooks.preSavePageFunction = function (options, callback) { return callback(err, responseData) }

Create a hook for your lookup data

We can use hooks to integrate custom code to perform calculations, data comparisons, or transformations and trigger functions to run at a specific point during the flow.

Step 1: Find the records

NOTE: If we already have the flow we open in Flow Builder, skip to Step 2: Create your hook Go go to integrator.io.

  1. Firstly Click the integration tile that has the flow with the records you want to map.

  2. The list, we click the flow you want to modify.

Step 2: Create your hook

  1. Firstly Click the hook icon in the lookup flow step.


The Hooks panel displays.


NOTE: The Hooks panel is a dynamic form. The editor fields may vary based on the app and the record type.

  1. Complete the following fields to define your hook:

    • Hook type:

      • Script: Code is managed and executed by integrator.io.

      • Stack: Code will be hosted on either your own server or AWS lambda.

    • Pre save page: In Pre save page integrator.io invokes this function at the end of each data record (after any applied transformations and filters). It invokes the lookup hook as the final step before passing the lookup record to another lookup or destination application.

      • Function: Firstly Enter the function you want the hook to trigger.

        • Pre map: Function you write in your script or stack will be triggered before the mapping.

        • Post map: Function you write in your script or stack will be triggered after the mapping.

        • Post Submit: Function you write in your script or stack will be triggered after the record is submitted.

        • Post aggregate: You write function in your script or stack will be triggered after all of the data has been gathered.

      • Scripts/Stacks: Please Select your script or stack from the drop-down menu. If you’re using a script, you can click Add (+) to add a new script or the pencil icon to edit an existing script.

    • Click Save or Save & close.



 
 
 

Comments


   Our Story

We’re a young and talented group of entrepreneurs and engineers with a groundbreaking idea designed to contribute towards a better tomorrow. We provide smart solutions for companies of all sizes and pride ourselves on our unparalleled, dedicated service. At KOMCLOUD PRIVATE LIMITED, we believe that the right understanding and technological edge can lead companies towards a successful future. Contact us today to set up a meeting with one of our sales representatives.

Our Division

We have Our Division in Pune That also works on Integration And Automation By using Technology such as Dell Boomi NetSuite SalesForce Etc.

Our Services

©2024-2025 by KOMCLOUD PRIVATE LIMITED.

  • Facebook
  • Twitter
  • LinkedIn
bottom of page