Checking entity compatibility

If you want to explicitly inform a user that a script will not work with a particular entity table or search you can throw an error from your script, for example:

async function fetchRecordData({ record, dataModelEntity }) {
  // It's best to bail out early if the script is used with an
  // unsupported data model entity.
  const rootEntity = await dataModelEntity.getRoot();
  if (await rootEntity.getLabel() !== 'Companies') {
    throw new Error('This script only works for Company records');


Next steps