Add support for cancellation

A template script can take time to complete, make sure it can be canceled when the user closes the Record Viewer or changes the record. To support cancellation, supply the cancelPromise input property to all the expensive queries of your script.

The following version of the script passes cancelPromise to the getLinkedRecords query to allow Investigate to cancel it when required.

async function enrichRecordData({
  source, record, dataModelEntity, cancelPromise, computedData
}) {

  const investments = await record.getLinkedRecords(
      size: 1000,
      orderBy: { field: 'raised_amount', order: 'desc' },
      cancelPromise // Pass the cancelPromise in the query options


Next steps

For more, see full example code.

To have your template script produce a downloadable report, see downloadable reports.