Reference an alias in a hook script to point to a connection, export, import, flow, or lookup cache without hardcoding its ID. This procedure is for developers who write hook scripts, such as preSavePage and postMap.
Prerequisites:
- The alias exists before you reference it. See Create an alias.
- Your script uses supported JavaScript runtime functions. Aliases apply only to those functions. For the list, see integrator.io API and JavaScript runtime objects.
Copy an alias into a hook script
- Go to Build
, and then select Flows.
- Open the flow.
- On the step that uses the hook, select ..., and then select the hook. On an export, select Pre save page hook. On an import, select Pre map hook, Post map hook, or Post submit hook.
- In the Hooks drawer, next to Scripts, select Edit script. It's unavailable until you select a script. To write a new script, select Create script.
- At the top right of the Script editor, select View aliases. On a narrow window, View aliases is in the ... menu.
- Find the alias for the resource.
- (Optional) In the Actions column, select View details to see more about the alias.
- In the Actions column, select Copy alias.
- Paste the alias where your script references the resource.
- If Auto preview is on, or you select Preview, the alias resolves and the output of the function appears.