JavaScript condition examples
The predefined workflows for cases, solutions, opportunities, and leads contain examples of Javascript conditions.
|
Entity name |
Rule name |
Example script |
|---|---|---|
|
Opportunity |
Reassign |
Copy
|
| Cases | Reassign |
Copy
|
| Lead | Reassign Lead |
Copy
|
| Lead | Edit Lead |
Copy
|
You can directly reference the fields of the workflowed record and return the field value. You cannot directly reference the fields of other records that are in context of the workflowed record. Instead, you can use CRM.GetContextInfo() to reference these fields and get data that's in context of the workflowed record.
You can use these techniques on custom entities to reference the fields of the workflowed record and return the field value.
The following is an example JavaScript condition on a custom entity called Project:
if (proj_stage != 'Planning')
{
Valid = false;
}
The following is an example JavaScript condition on a custom entity called Project that's a child of Company:
if (proj_stage == 'Planning' && CRM.GetContextInfo("company","comp_type")=='Customer')
{
Valid = false;
}
else
{
Valid = true;
}
