Sage CRM Create Scripts provide a powerful tool for implementing business rules. These scripts are executed on the server side whenever a screen is created. This allows system administrators to control how a screen behaves. They allow administrators to enforce specific business logic as a screen loads. They can be used for tasks like setting default values for fields, checking data for accuracy, or triggering specific actions when the screen loads.
- Create Scripts in Sage CRM are written at the level of the field.
- Each field within a screen in Sage CRM can have its own Create Script.
- This script specifically targets the field it's attached to and can access and modify data related to that particular field.
- While a Create Script can't directly manipulate other fields on the screen, it can trigger actions that might affect them indirectly, like setting error messages.
- Create Scripts themselves cannot directly stop the record from being committed but when used with Validation rules they can enforce business rules.
Sage CRM offers two other types of Field Level Scripting:
- Validate Scripts
- These scripts run on the server-side when a user attempts to save a record. Their primary function is data validation. Validate Scripts can check the data entered in the field against pre-defined criteria and prevent the record from being saved if the data fails validation. They can also set error messages to guide the user towards correcting the issue.
- OnChange Scripts
- These scripts are executed on the client-side (user's web browser) whenever the value in the field is changed. They offer more flexibility for dynamic behavior on the user interface. OnChange Scripts can be used for various purposes like:
- Updating other fields based on the changed value.
- Triggering calculations or data lookups based on user input.
- Providing real-time feedback to the user regarding data validity or potential issues.
- These scripts are executed on the client-side (user's web browser) whenever the value in the field is changed. They offer more flexibility for dynamic behavior on the user interface. OnChange Scripts can be used for various purposes like:
Each script type has its own scope and functionality. System Administrator should choose the appropriate script based on what they want to achieve:
- For initial setup and default values: Create Scripts
- For data validation during save: Validate Scripts
- For dynamic behaviour as the user interacts with the field: OnChange Scripts
Below are the links to articles covering all aspects of work with Create Scripts
Understanding Context, Scope of Reference and Scope of Effect
- Scope of reference refers to the visibility and accessibility of variables, functions, and other named elements from a specific point in your Create Script. It's about where you can look to find the definition of something you're using.
- Scope of effect focuses on the parts of your Create Script that are actually modified or impacted by a particular function or method. It's about what parts of Sage CRM experience the changes introduced by a specific script.
- How can I get the SID in Serverside scripting?
- CurrentUser object in Serverside Code
- The Values() collection
- How did I get Here?
- Objects Available in the Internal COM API
- Understanding GetContextInfo()
- Getting Hold of User Information in Code
Create Scripts and Security
Controlling Screens
- Overriding User Preferences in a Screen e.g. currency settings (decimal places)
- Adding a new Panel to a Summary screen e.g. Company Summary
- Working with a Person's Address Type
- CRM.AddContent() & Dummy Field Trick
Controlling Fields in Screens
- Using a Create Script to produce an automatically incrementing number.
- The display of a photo or image in the person screen
- Displaying an Image on a Custom Entity Page
- Working with Selection Lists
- Using SearchSQL to limit data returned by selection lists
- Controlling the Display of Drop Down Options in Team Select Fields
- Using a Function in a CreateScript
- Populating Default Date Field Values
- Hyperlinking to a parent Custom Entity from a Search Select Advanced Field
- Setting a Default Value of a Child record's field based on the value of a field in a Parent record
Controlling Fields in Search Screens
- Using a Create Script to control a Search Screen
- Field Level Scripting in Search Screens
- Controlling Default Values in Search Screens
Controlling Fields in Screen TopContent
Controlling Columns in Lists
- Using Create Script in GridColumns
- How to Hide the Assigned User Column in the Case List when in My CRM context
Create Scripts in Workflow
Mobile