Add a Code step
- In Workflow Builder, click + under the trigger, search for Code, and select Code Block.
- In the step’s Configure tab, open the code editor, replace its contents with the sample code, and click the check mark to close the editor.
- Click Save > Save draft.
- Run the flow with your saved payload, as described in Run the flow with a saved payload.
- In Run history, click Code Block. Check the purchase order on its Output tab, and the lines the code logged on its Logs tab.
How the code reads your ION connection
When a Code step runs, it receives the flow’s config variables asconfigVars. Your ION connection is one of them. Its fields hold the Client ID as clientId and the Client Secret as clientSecret. The sample finds the connection that has a clientId, and exchanges the two for an access token, so you never paste credentials into the code.
The code reads the trigger’s output from stepResults. The purchase order’s ID is at results.body.data.data.id.
Sample code
This sample gets an access token, then queries the purchase order the trigger fired for:The sample’s URLs point to the US sandbox, so the ION connection must use sandbox API keys. For another region or environment, replace
tokenUrl and apiUrl with that environment’s auth server and API endpoint from ION environments.