trigger addSalesRepToLCR on LawyerConnectionRequest__c (before insert, before update)
{
if (Trigger.isUpdate || Trigger.isInsert)
{
Set<Id> contactIds = new Set<Id>();
for (LawyerConnectionRequest__c lcrToGetContactIds : Trigger.New)
{
contactIds.add(lcrToGetContactIds.Client__c);
}
Map<Id, Contact> mapOfUsers = new Map<Id, Contact>([select Id, Owner.Id, Owner.Profile.Name from Contact where Id In :contactIds]);
for (LawyerConnectionRequest__c lcr : Trigger.New)
{
if (lcr.Client__c != null)
{
Contact newUser = mapOfUsers.get(lcr.Client__c);
if (newUser.Owner.Profile.Name == 'Rocket Lawyer Sales')
{
lcr.Sales_Rep__c = newUser.Owner.Id;
}
}
}
}
}
0.000000
0.000000
Like this:
Like Loading...
Related
Published by Thys Michels
Cloud Architect - Salesforce and everything related
View all posts by Thys Michels