Articles in this section
Using Custom Server Scripts in Processes, Workflows, and Approvals
Table of Contents
Introduction
These are server-side code executed on a record save, approval, or rejection. They can be configured in workflows, processes, or approvals and triggered on selected actions. These scripts get record data (which is getting saved) as well as user data. If any change is made to record data and returned, changed data will be updated back to the CRM record (like an update field action).
This should be used for lighter operations like updating some field data based on complex logic, which is impossible through workflow expressions, creating records in other modules based on some logic and different mapping, sending emails through external services on certain conditions, etc. These scripts are run immediately and block the save operation. If your script takes more time, record save also will become slower.
Use Cases
- Contact email validation and data enrichment
- Retrieve customer credit scores from an external service and synchronize with CRM.
- Update Organization's outstanding invoice amount
- Create or update related record by merging CRM data and data from external source
Code Format
async function main(record, user) { //Type your code here return record; } |
- record - Data of CRM record getting saved having record id, module name, label and all field values.
- user - Current user data including user id, label, role, preferred currency details, timezone and all field details.
You can test the server scripts as soon as you write the code in workflows, processes and approvals with the option provided to select a record and verify the code. Once the test is executed, you will see a response with the text status, execution time, input, output, etc. You can see the logs once published. For Process, you will see a Logs tab beside the script and for Workflows and Approvals, you can access the logs from the List View.
Kindly refer this document to learn more about how to code, helper methods, etc.
Note:
|