You are reading the documentation for an outdated Corteza release. 2023.9 is the latest stable Corteza release.

Modifying built-in scripts

Modification of built-in scripts

If you wish to modify an automation script that is defined by another extension (such as CRM scripts) you have two options; to create a modified copy or overwrite scripts.

Create a modified copy

To modify the extension:
  1. copy the extension source (clone the repository or copy the files),

  2. modify the source as you see fit,

  3. deploy your version instead of the original version.

Overwrite the scripts

Corredor assigns unique names to each automation script. The name is generated from the file path.

For example:
# The CRM extension
/ server-scripts
  / crm
    / Lead
      / SetLabel.js

The SetLabel.js script script is assigned /server-scripts/crm/Lead/SetLabel.js:default as the name.

To overwrite the SetLabel.js script, you must define a script that will be assigned the same name (essentially has the same path).

For example:
# The CRM extension
/ package.json
/ node_modules
/ server-scripts
  / crm
    / Lead
      / SetLabel.js # 👈 We're targeting this one
      / AnotherScript.js

# Your extension
/ package.json
/ node_modules
/ server-scripts
  # To overwrite something in the CRM extension
  / crm
    / Lead
      / SetLabel.js # 👈 This version will replace the CRM version

  # The rest of your code goes here
  / extension
    / Lead
      / SomeScript.js

For this to work, you must make sure that your extension is included after the extension you wish to modify.

For example:
# This will NOT work; the CRM is included after
CORREDOR_EXT_SEARCH_PATHS="/your-ext:/crm"

# This will work; the CRM is included before
CORREDOR_EXT_SEARCH_PATHS="/crm:/your-ext"