Articles in this section

Export hooks

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

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 Data Loader. Hooks cannot make changes to a “blob” (file download passed intact within a flow). 

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

Hook type JavaScript Stack SuiteScript 1.0 SuiteScript 2.0

preSend

   

x

x

preSavePage

x

x

   

In NetSuite integrations, the script format used for hooks should be the same as the NetSuite API version used in the export.

Hook types

  • Script – integrator.io manages and executes your code
  • Stack – Your own server or AWS lambda hosts your code

See also

Was this article helpful?
2 out of 4 found this helpful

Comments

9 comments
Date Votes
  • Excellent article as I get into more javascript hooks. Question: in testing and using the preview functionality of the j-hook window, is there a way to preview with more than a single object in the data[] array? Even with "All" selected in the initial export flow step, I only get data[0].

    Thank you!

    Jim Kelleher

    (As an aside, love that you use i, j, and k as iteration variables. Takes me back to my Fortran days.)

    0
  • Hi PSA Admin!
    Thanks so much for the great feedback! Speaking of old languages, I still try to forget my COBOL days! ;-D I'm checking into the answer on this for you and will get back to you asap.

    0
  • Hi PSA Admin,

    For now, you need to copy and paste or type in additional records into the data[] arg. We're looking at having the ability to preview more than one record in the export panel for next year, which will make this process easier. You letting us know about this need is helping us consider adding the ability to pull more than one record into the Advanced Field Editors (AFEs), so thank you!

    0
  • I would also like the same functionality described by PSA Admin. Whenever I need to test against more than one object I must copy it from the debugger and then paste it into the template. It would save a lot of time to have this functionality.

    0
  • Hi Shane Brown,

    Thanks so much for letting us know. Could you post this enhancement idea to our community in the enhancement requests area? We are working on a feature to store and view sample data throughout the flow to show how it's being impacted at each step, as a result of PSA Admin's insights in improving this experience. Would you be interested in previewing what we're designing now? 

    PSA Admin, we're already planning to show you what we're working on :). Thank you so much for your invaluable help!

    0
  • Here is the scenario: 
    1. We have a export to get tickets api on Zen Desk (Each Ticket has some custom fields). In the output of exports, we get ticket records. Each ticket body has custom fields, in custom fields we have its id and the value.

    2. We have a 2nd export that calls the get ticket fields api on Zen Desk which returns all the custom fields and each custom field has an id, a title etc. along with other details. We want to extract only the custom field id and title.

    3. For every custom field in the ticket, we want to add a name field in the tickets body under custom field, the one extracted from step2 for the matching custom field.

    Is there a way where we can do this. I could not find a way where a single hook/script can work for more exports. Any help will be appreciated.

    0
  • Hi Mahesh Shet

    You should consider posting this question to our community, as you'll get a quick response and ideas! In my opinion, you can make this happen easily using Transformations 2.0. One of its specific scenarios is managing data when there are multiple exports. There's a video in the link and examples from our CTO that can help you out! 

    Thanks, 

    Kathyana

    0
  • Mahesh Shet there are a few ways to do this and each way is a different difficulty level.

    1. You could have a lookup step to lookup each individual ticket field with it's id to get the title of the field. This would be pretty inefficient because you would end up making a lot of duplicate api calls and an api call for every single ticket/custom field combo. The benefit is you wouldn't need a script unless you want to flatten out the structure of the custom field array.
    2. You could have a lookup that makes one api call per page of records and that api call gets a list of all custom fields for tickets. Once you've done that, you would need a postResponseMap script to basically lookup the custom field ids to the returned id/title response array. This would be a lot more efficient compared to the first option, but does require an api call per page of records and does require a semi complex script.
    3. You could use a preSavePage script on your initial export to run a virtual export that grabs all the ticket fields and then does the same thing as #2. This would be as efficient as far as your number of apis calls, but requires a slightly more complex script since it's running a virtual export.
    4. You could create 1 flow that gathers all the custom fields from Zendesk, updates the settings of flow #2 so it has reference to what all fields are available, then flow 2 has a script to do the same as #2. In this case, flow 1 would always run before flow 2 to fetch the latest list of custom fields and then flow 2 would be triggered to run after flow 1 is complete. This would be the most efficient option as far as number of api calls to Zendesk because you would be making 1 api call to get all ticket fields.

     

    I've put together an integration zip that shows all these options and a quick video overview. Sorry for the bad audio, I recorded with the wrong microphone🙄.

    https://drive.google.com/file/d/1cGsDRygi-zoljBjsNfAPQdeHYXVpdb2P/view?usp=drive_link

    https://app.screencast.com/thmj2S40UjEK2

    0
  • Dave Guderian the above integration would help in your HubSpot case as well.

    0

Please sign in to leave a comment.