Skip to main content
The following JavaScript samples illustrate common patterns for Custom activity scripts — OAuth authorization, sending exports to external services, modifying extracted fields, manipulating tables, generating custom JSON, and retrieving source file names. Copy and adapt them to your own field names and endpoints.

Authorize via OAuth and send export data to an external service

The following script performs authentication using a token obtained via Resource Owner Password Flow and then sends the export data to an external service:

Send export data to an external service

The following script names the exported file using the invoice number and then sends export data to an external service (Dropbox in this case):

Modify extracted data

The following script modifies the value of an existing field and adds new values for a repeating field using information contained in a response from an external service:

Retrieve data from a specific table column

The following script writes all values (rows) of the Description table column to the transaction event log:

Retrieve data from all table columns

The following script writes all values (rows) of all table columns to the transaction event log:

Add rows to a table

The following script adds new table rows and sets values for the Description and Quantity table columns:

Delete rows from a table

The following script deletes all rows from a table:

Delete a specific instance of a repeating field

The following script deletes the last instance of a repeating field:

Generate a JSON file and send it to a third-party system

The following script generates a JSON file in a custom format and sends it to a third-party system:

Retrieve original file names

The following script puts the original name of a file into the MyField field: