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, search) {
const { DataRecord, DataModelEntity, Relation } = sirenapi;
// It's best to bail out early if the script is used with an unsupported search.
const rootSearch = await search.getRoot();
if (await rootSearch.getLabel() !== 'Companies') {
throw new Error('This script only works with the Companies entity table.');
}
...
}
Next steps
-
To add asynchronous rendering to your script see asynchronous rendering.