Home  >   FAQs   >  What is a Server Script?
FAQs in this section

What is a Server Script?

Table of Contents
Scripts are triggered on a record save, approval, or rejection. Scripts 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.
 

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.
Was this FAQ helpful?
0  out of  0  found this helpful.
Comments 0
Be the first to comment
© Copyright 2023 Vtiger. All rights reserved.