Plauti Assign out of the box supports the Lead, Account, Contact, Opportunity, Case, and Task objects. However, with a little extra setup we can apply the same automatic assignment capabilities to any Object with a User field (either the OwnerId or a custom user lookup field). So you can automatically assign Custom Objects and other Standard Objects like you can with Leads.
It is recommended, and in most cases required, that you perform these steps on a Sandbox org and then push the changes to your Production org via a Change Set. These instructions assume some familiarity with the creation and use of Sandboxes, Apex and Change Sets. This whole process should take approximately 10 minutes for someone familiar with this aspect of Salesforce administration.
Configuration Steps for other Standard and Custom Objects
This article is not intended for Lead, Account, Contact, Opportunity, Case, or Task assignment. For those Objects, see Enable or disable Assign for default Objects.
Add Plauti Assign fields to your Object
Add the following Plauti Assign fields to the Custom Object or Standard Object whose records you want assigned by Plauti Assign.
- Go to Salesforce Setup > Object Manager, and find your Object.
- Click Fields & Relationships > New.
- Add a (single-value) Picklist field:
- Set Field Label to ‘Use Plauti Assign’.
- Change the Field Name to
Use_Round_Robin. - Add the following six values (uppercase):
TRUEQUEUEDFALSEASSIGNEDREJECTEDNOMATCH
- Set TRUE as the default value of the picklist.
If you plan to use automation to set the field value to TRUE, deploy the trigger first and then set the default to FALSE. - Leave the other settings at their default values and Save.
- Add a Text Area (Long) field:
- Set Field Label to ‘Plauti Assign Info’.
- Set Length to ‘5000’.
- Change the Field Name to
Round_Robin_Info. - Leave the other settings at their default values and Save.
- Add a Number field:
- Set Field Label to ‘Plauti Assign Index’.
- Change the Field Name to
SRRIndex. - At ‘Establish field-level security’, leave the field level security at their default values.
- At ‘Add to page layouts’, unselect the page layout checkboxes; this field should not be on a layout.
- Then Save.
Keep Field Names as stated
Make sure the Field Names of the added fields are changed to exactly as stated here, else they will not work. The Field Labels can be different if you want.
Add a Trigger to your Object
- Still on the Object Manager page for your standard or custom object, at left, click Triggers.
- Click New. Remove the default trigger code but remember the API name of your Object that is mentioned in the first line.
- Copy and paste the trigger code below into the code window. Important: replace
Custom_Object__con the first line with the API name of your object. If your object is named ‘Super Widgets', the API name is usuallySuper_Widgets__c. If it is a standard object like Campaign, the API name will just beCampaign.
trigger assign on Custom_Object__c (before insert, before update, after insert, after update) {
switch on trigger.operationType {
when BEFORE_INSERT,BEFORE_UPDATE {
leadassist.ArgonSRR.runSuperRoundRobin(Trigger.New, trigger.isInsert);
}
when AFTER_INSERT {
leadassist.ArgonSRR.runMatchLogs(Trigger.New, true, null);
}
when AFTER_UPDATE {
leadassist.ArgonSRR.runSLACheck(Trigger.New, Trigger.Old);
}
}
}Add a Test for your trigger
For any trigger to be deployed to production you must have a test class. The following instructions should be completed after you have created the trigger and you have established that Plauti Assign operates as expected on your newly triggered object.
- Go to Setup > Apex Classes > New
- Name the class PATriggerTest. If you have several triggers that need testing, either have a new test class for each one, with distinct names, or if you are comfortable with Apex you can duplicate the relevant sections in the test code below as many times as required for the triggers that need testing.
- Copy and paste the test code below into the code window. Each line that is preceded with a "//Config required:" line must be configured with values specific to your trigger and object. These sections are in bold type. Only change the sections of code in bold type.
Note: if your version of PA is pre Version 9.40, or pre Version 2 for PA Lite, use this test class code.
//test class for Plauti Assign triggers on custom objects, and standard objects beyond the out-of-the-box Lead, Account, Contact, Opportunity, Task and Case
//if you are required to put customer specific configuration into this test class, there will be a comment starting '//Config required:' in the preceding line telling you what to do
@isTest
private class PATriggerTest {
@isTest
static void testPATrigger() {
//Config required: objectType is the API Name for the object you created the trigger on. e.g. My_Custom_Object__c or Campaign. This example is for Campaign.
String objectType = 'Campaign';
//Config required: objectAssignmentField: by default OwnerId is the field Plauti Assign assigns to. If you are configuring a child object replace OwnerId here with the User Lookup field you are assigning with PA
String objectAssignmentField = 'OwnerId';
//Config required: objectFieldName: select a field from the object that this test will create a Match Rule with. Easiest is to use a String field like Description
String objectFieldName = 'Description';
//Config required: objectFieldValue: the value in the objectFieldName that will cause a positive match. If you set the objectFieldName to 'Description' then put 'DescriptionValue' here.
String objectFieldValue = 'DescriptionValue';
leadassist__MatchGroup__c mg = leadassist.TestDataFactory.setupTestAndReturnMatchGroup(objectType,objectFieldName,objectFieldValue,objectAssignmentField);
Decimal leadcount_before = mg.leadassist__leadcount__c;
//Config required: this line of Apex code creates a new record of the object you created the trigger on. This test example is for the Campaign object. Remember to include any required fields, and the matching field you set above (Description in this example)
Campaign newRecord = new Campaign(Description='DescriptionValue', Name='Example Campaign', Status='Planned', Use_Round_Robin__c='TRUE');
Test.startTest();
insert newRecord;
Test.stopTest();
Campaign cm = [select Id from Campaign where Id = :newRecord.Id];
update cm;
leadassist__MatchGroup__c mgAfter = [select leadassist__leadcount__c from leadassist__MatchGroup__c where Id = :mg.Id];
Decimal leadcount_after = mgAfter.leadassist__leadcount__c;
System.assert(leadcount_after == leadcount_before+1);
}
}
When you have finished configuring this test class, click Save. If it gives you a 'compile' error, it is likely that you have introduced some kind of syntax error. Look very carefully at the code here and compare it to your code. Each line must have a semi colon at the end. Any opening parenthesis must be matched with a closing parenthesis. Any comment lines (starting //) must be on a single line - do not introduce line breaks into those comment lines. All required fields must be included when you create the new record. That includes any fields required due to validation rules. Any variable values for objectType and objectFieldValue fields must be surrounded in single quotes.
If you get a compile error saying that the method TestDataFactory.setupTestAndReturnMatchGroup is not visible, check and ensure in the Version Settings of the test class that it is pointing to the latest (installed) version of Plauti Assign. This error is produced if it is pointing to an older version of Plauti Assign.
Once you have checked all the above and it is still complaining, send us your test code via Plauti.com/Contact and we will look over it.
Once saved, you will see a row of buttons above the code - click the 'Run Test' button. If the trigger and test code has been set up correctly, the test will pass and you will be able to add the trigger and the test class to your Change Set, ready for deployment to production. Read more about Change Sets in the Salesforce Help documentation.
That's everything you need to do to enable any object to be processed by Plauti Assign. Need help? Contact us via Plauti.com/Contact.