You need to sign in to do that
Don't have an account?
Code help - won't recognize both roles
Hey all,
Something is wrong with the code below - it only works (updated Discovery Call Note datetime) if role = Account_executive
How can I update it to also work for Strategic_Account_Executive?
public class ContentDocumentLinkTriggerHandler {
/*
*/
public static void OnAfterInsert(List<ContentDocumentLink> newContentDocumentLink, List<ContentDocumentLink> oldContentDocumentLink, Map<ID, ContentDocumentLink> newContentDocumentLinkMap, Map<ID, ContentDocumentLink> oldContentDocumentLinkMap){
/*
*/
UserRole accountExecutiveRole = [Select Id From UserRole WHERE DeveloperName = 'Account_Executive' OR DeveloperName = 'Strategic_Account_Executive' LIMIT 1];
List<User> AEUserIdList = [SELECT Id FROM User WHERE UserRoleId = :accountExecutiveRole.Id];
Map<Id, ContentDocument> contentDocumentMap = new Map<Id, ContentDocument>([SELECT OwnerId, Description FROM ContentDocument WHERE OwnerId IN :AEUserIdList]);
Set<Id> opportunityIdSet = new Set<Id>();
Map<Id, ContentDocumentLink> opportunityContentDocumentLinkMap = new Map<Id, ContentDocumentLink>();
for(Id ContentDocumentLinkId: newContentDocumentLinkMap.keySet()){
if(!RecursionCheck.IsRecordIdInSet(ContentDocumentLinkId, 'After')){
if(String.ValueOf(newContentDocumentLinkMap.get(ContentDocumentLinkId).LinkedEntityId).StartsWith('006') && ContentDocumentMap.KeySet().contains(newContentDocumentLinkMap.get(ContentDocumentLinkId).ContentDocumentId)){
opportunityIdSet.add(newContentDocumentLinkMap.get(ContentDocumentLinkId).LinkedEntityId);
opportunityContentDocumentLinkMap.put(newContentDocumentLinkMap.get(ContentDocumentLinkId).LinkedEntityId, newContentDocumentLinkMap.get(ContentDocumentLinkId));
}
RecursionCheck.AddRecordIdToSet(ContentDocumentLinkId, 'After');
}
}
//List<ContentDocument> cdList = [SELECT Id, Title, CreatedDate, Description, ParentId, LatestPublishedVersionId FROM ContentDocumentLink WHERE Id = :];
Map<Id, Opportunity> opportunityMap = new Map<Id, Opportunity>([Select Id, StageName, RecordTypeId, Discovery_Call_Date__c, Use_Case__c, Type, Amount, Discovery_Call_Note_Datetime__c FROM Opportunity WHERE Id IN :OpportunityIdSet]);
for(Id oppId: opportunityMap.keySet()){
if(opportunityMap.get(oppId).StageName == 'Qualify'){
opportunityMap.get(oppId).Discovery_Call_Note_Datetime__c = System.Now();
}
}
// TODO: should I use this or the regular update?
Update opportunityMap.values();
}
}
Pg In Ahmedabad - Boys And Girls
Latest Love Shayari in Hindi, True Love Status, Best Love Sms Whatsapp status
Best Love Shayari in Hindi Whatsapp status
Love Shayari in Hindi, True Love Status, Best Love Sms Whatsapp status
Bewafa Shayari In Hindi
Paying Guest In Ahmedabad - Boys And Girls
Attitude Status
Attitude Shayari In Hindi For Love (
Attitude Shayari
Attitude Status
Best Shayari in Attitude Shayari
Hindi Shayari On Positive Attitude
Khatarnak Attitude Shayari
Hindi Shayari On Positive Attitude Boy
Hindi Shayari On Positive Attitude Girl
Khatarnak Attitude Status
Royal Attitude Status
Royal Attitude Status In Hindi
Pg In Ahmedabad - Boys And Girls (https://www.notshout.com/p/pg-in-ahmedabad.html)
Latest Love Shayari in Hindi, True Love Status, Best Love Sms Whatsapp status (https://www.notshout.com/2020/03/latest-love-shayari-in-hindi-true-love.html)
Best Love Shayari in Hindi Whatsapp status (http://https://www.notshout.com/2020/03/best-love-shayari-in-hindi-notshout.html)
Love Shayari in Hindi, True Love Status, Best Love Sms Whatsapp status (https://www.notshout.com/2020/03/love-shayari-in-hindi-true-love-status.html)
Bewafa Shayari In Hindi (https://www.notshout.com/2020/03/bewafa-shayari-in-hindi.html)
Paying Guest In Ahmedabad - Boys And Girls (http://www.staywellahmedabad.com/pg-in-ahmedabad.php)
Best Shayari in Attitude Shayari (https://www.notshout.com/2020/03/best-shayari-in-attitude-shayari.html)
Hindi Shayari On Positive Attitude (https://www.notshout.com/2020/03/hindi-shayari-on-positive-attitude.html)
Khatarnak Attitude Shayari (http://Khatarnak Attitude Shayari )
Hindi Shayari On Positive Attitude Boy (https://www.notshout.com/2020/03/hindi-shayari-on-positive-attitude-boy.html)
Hindi Shayari On Positive Attitude Girl (https://www.notshout.com/2020/03/hindi-shayari-on-positive-attitude-girl.html)
Khatarnak Attitude Status (https://www.notshout.com/2020/03/khatarnak-attitude-status.html)
Royal Attitude Status (https://www.notshout.com/2020/03/royal-attitude-status.html)
Royal Attitude Status In Hindi (https://www.notshout.com/2020/03/royal-attitude-status-in-hindi.html)
Attitude Status (https://www.notshout.com/2020/03/attitude-status.html)
Attitude Shayari In Hindi For Love (https://www.notshout.com/2020/03/attitude-shayari-in-hindi-for-love.html)
Attitude Shayari (https://www.notshout.com/2020/03/attitude-shayari.html)
Attitude Status (https://www.notshout.com/2020/03/attitude-status_15.html)
https://www.bhojpuriyadhamaal.com/2020/01/bhojpuri-actress-name-photo.html
This is written by the blog BHOJPURIYA DHAMAAL (https://www.bhojpuriyadhamaal.com/)
Did you check if the developer name for Strategic_Account_Executive is accurate as in code.
Please query again with below and cross verify the developer name or Add debug statements after fetching the results in accountExecutiveRole and see the output for accountExecutiveRole.id. If its able to fetch the Id, problem might be in other piece of code.
Hope this helps!
Thanks