Using InsertRecord in a table-level script
This example uses the InsertRecord function in a table-level script. The script assigns new cases to the account manager of the selected company. You must disable Workflow for Cases before trying this example.
- Create a new script. For instructions, see Creating a script.
When creating your script, do the following:- From Script Type, select Table Level.
- In Table level script, within the function InsertRecord section, enter the following script:
- Click Save.
function InsertRecord()
{
// when case is created this sets the assigned user to be the account // manager of the company selected
iPrimaryUserID = CRM.getContextInfo('company','comp_primaryuserid');
if (iPrimaryUserID > 0) {
Values('case_assigneduserid') = iPrimaryUserID;
}
}
Now when you create a new case for a Company but don't assign the case to a user, the case is automatically assigned to the company account manager when you save it.