• Olesja Sandiba
  • 0 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 1

Hello everyone, I have a question connected with exclusion of some profiles from method in Apex Class.
I have a method in CaseManagment class, which prevent closure of Case when case have email drafts. But, for some purposes this function have to work for all profiles except "Sales Manager" ,  "Sales Backoffice" profiles. How can i exclude this profiles from function?

         Id StandardRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('Case_Standard').getRecordTypeId();
        Map<String,Boolean> emailMessageMap = new Map<String,Boolean>();
        List<Case> closedCasesList = new List<Case>();
        for(Case c : newMap.values()){
            if(c.RecordTypeId == StandardRecordTypeId){
            if (c.Status != oldMap.get(c.Id).Status && c.Status == 'Closed'){
        List<EmailMessage> emailMessageList = [SELECT ID,Status,RelatedToId FROM EmailMessage WHERE RelatedToId IN:closedCasesList AND Status='5'];
        for(EmailMessage em : emailMessageList){
        for(Case c : closedCasesList){
            if (emailMessageMap.get(c.Id)!=null){
                c.addError('Email Draft exist');

I have a method that identify current user profile, but how it use in this case? 

Id currentProfile=userinfo.getProfileId();
       Profile profileName=[Select Name from Profile where Id=:currentProfile];

Thanks in advance!

I'm doing the simple lightning components challenge and have hit this problem in my existing trailhead org and a brand new dev org that I've just created:

Challenge not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: QVWBQHAG