• Mohan kumar 167
  • NEWBIE
  • -2 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 2
    Replies
Hi,
I have to enable birthdate remainder boolean check on contact, If the contact birthdate reaches to 20, 21 and 28 years with in 40 days of the contact birthdate. for example if the contact reaches 20 years in next 40 days then we have to enable boolean check on contact that means we have to enable boolean after contact age is 19 years 10 months and 20 days till he reaches to 20 only not more than 20 like wise for 21,28 years.
I tried following formula but it is not working as expected and It considers the after 20 years and 40 days also but I want before 40 days.
IF( AND( NOT( ISBLANK( Birthdate ) ) , OR(YEAR(TODAY()+40) - YEAR(Birthdate) = 20,YEAR(TODAY()+40) - YEAR(Birthdate) = 21,YEAR(TODAY()+40) - YEAR(Birthdate) = 28),DATE(YEAR(TODAY()),MONTH( Birthdate ),DAY(Birthdate )) <= (TODAY() + 40)) , true,false)

Thanks,
Mohan
Hi All,
I have removed record type from the profile but, user is still able see the record type when creating new record. I have checked default recort types on user personal settings, The removed record type is available on the default recort types on user personal settings. I try to remove this record type but there is no remove option over there. How do we remove it and what might be the reason for this.
Hi All,
I am not able to give any record Id, User Id In Recipient id field on Lightning flow notification action. What exactly It is. What we need to give on this field and what is Target Id.

Thanks
Mohan
Hi,
     I am getting following Issue when i opening Patients in Health Cloud. I have Installed one month free trail version managed package in my org. Please some help me how to resolve this.
"Something's not quite right. Try your action again, and if the issue continues, contact your administrator for help"

Thanks,
Mohan
Hi,
      I have seen that health cloud is available only for Enterprise, unlimited and proffessional editions only how do we practice health cloud in developer edition. Can any one share the trailhead modules and referenses. If we have possibility to install the health cloud in DE please suggest how do we install and use it.

Thanks,
Ram
Hi,
     I have logged in as community user and try to creating the opportunity but, community user getting Insufficient privelege error while creating the opportunity. The community user have create and edit permission on account,opportunity and have edit permission on all the fields. Can any one tell me the reason why the community user getting this error?
Hi,

      I am unable to add the opportunity team member after AccountShare is inserted.After adding the account team member to account team, We have custom button after click on the button we have to share the account associated child acccounts and  add account team member as opportunity team members after inserting the accounrShare.  Following is my code. Please tell me the Issue in the below code

public without sharing Class RefreshAccountTeamCtrl{
   
    Id accountId;
    static Integer delRecs;
   
   public RefreshAccountTeamCtrl(ApexPages.StandardController controller){
        
        accountId = ApexPages.CurrentPage().getParameters().get('Id');   
        system.debug('DEBUG:Accountid '+accountId);
    }
    public PageReference refreshTeam(){
       
        
        List<AccountTeamMember>  accTeamLevelAList = [select id, 
                                                      accountid,
                                                      teammemberrole, 
                                                      accountaccesslevel, 
                                                      userid 
                                                      from AccountTeamMember 
                                                      where accountid = :accountId and lastmodifieddate > yesterday]; 
        system.debug('DEBUG:account team map size'+accTeamLevelAList.size());
        
        Map<Id,AccountTeamMember> accTeamMap = new Map<Id,AccountTeamMember>();
        
        if(accTeamLevelAList != null){
            for(AccountTeamMember acc : accTeamLevelAList){
                accTeamMap.put(acc.userid,acc);  
            
            }
        }
        system.debug('DEBUG:account team map '+accTeamMap);
        Map<Id,Account> acc1Map =new Map<Id,Account>([select id, 
                                                            parentid 
                                                            from Account 
                                                            where Parent__c =:accountId ]); // Get all the child accounts of level A
        if(acc1Map.isEmpty() || acc1Map == null){            
            return null;
        }                                            
        
        // Key is the id of each Level B account and
        Map<Id, Account> acc2Map = new Map<Id, Account>([select id , 
                                                            parentid 
                                                            from Account 
                                                            where Parent__c IN : acc1Map.keySet()
                                                            ]);
        if(acc2Map.isEmpty() || acc2Map == null){        
            return null;
        }                                            
       
        Map<Id, Account> acc3Map = new Map<Id, Account>([select id , 
                                                            parentid,ownerid 
                                                            from Account 
                                                            where Parent__c IN: acc2Map.keySet()
                                                            Order by createdDate]);
        if(acc3Map.isEmpty() || acc3Map == null){            
            return null;
        }
        
        List<Id> accList = new List<Id>();
        accList.addAll(acc3Map.keySet());
        
       
        List<AccountTeamMember> accTeamDelList =  new List<AccountTeamMember>();
        system.debug('DEBUG: no of deleted records '+delrecs);
        system.debug('DEBUG:before check delta '+accTeamMap.keySet());
        // Check delta, if the inserted records are already there in the location accounts
        // remove them from the map
        system.debug('DEBUG: delta account '+accList[0]);
        //accTeamMap = checkDelta(accList[0],accTeamMap); //commented as per case #00286815
        system.debug('DEBUG:After check of delta '+accTeamMap.keySet());
        //if(delrecs == 0 &&  accTeamMap.isEmpty()){
        if( accTeamMap.isEmpty()){
           // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'No Records Added'));
            
            return redirect();
        }
        //Integer size = delrecs + acc3Map.size()*accTeamMap.size()*2;
        Integer size =  acc3Map.size()*accTeamMap.size()*2;
        system.debug('DEBUG: acc3Map size '+size);
        
        // If the no of records are greater than 2000 to be inserted or deleted send it to batch
        if(size > 2000){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Batch is currently in progress, Please Click on "Back" to go to the previous page. You will be notified once the batch is executed'));
            runBatch(acc2Map.keySet(),accountId,accTeamMap,accTeamDelList);
            return null;
        }
        
        /*if(accTeamDelList != null && !accTeamDelList.isEmpty()){
            try{
                Delete accTeamDelList;
            }
            Catch(Exception exe){
                system.debug('DEBUG : exception caught while deleting '+exe.getMessage());
                
            }
        }*/
        if(accTeamMap.isEmpty()){
            return redirect();
        }
        
        // getting all the share access records for acc team members.
        Map<Id,AccessLevel> accslevelMap  = getSharerecords(accountId,accTeamMap.keySet()); 
        
        List<String> accountShareJSONList  = new List<String>();
        //List<AccountShare> insertShareList = new List<AccountShare>();
        List<AccountTeamMember> insertTeamList  = new List<AccountTeamMember>();
        
        for(Id userId : accslevelMap.keySet()){
                for(Id accId : acc3Map.keySet()){
                String access; 
                AccountTeamMember acc  =  new AccountTeamMember(userid = userId,
                                                                AccountId = accId,
                                                                TeamMemberRole = accTeamMap.get(userid).TeamMemberRole);
                
                // AccountAccessLevel = accslevelMap.get(userid).accLevel);
                insertTeamList.add(acc); 
                if(userId != acc3Map.get(accId).ownerId){    
                    if(accslevelMap.get(userid).accLevel == 'Read' || accslevelMap.get(userid).accLevel == 'Edit'){
                        access = accslevelMap.get(userid).accLevel;
                    }
                    else{
                        access = 'Edit';
                    }
                    AccountShare accShare  = new AccountShare(UserOrGroupId = userId, 
                                                              AccountId = accId,
                                                              AccountAccessLevel = access ,
                                                              OpportunityAccessLevel = accslevelMap.get(userid).oppLevel,
                                                              ContactAccessLevel = accslevelMap.get(userid).conLevel,
                                                              CaseAccessLevel =  accslevelMap.get(userid).caslevel);
                    accountShareJSONList.add(JSON.serialize(accShare));
                //insertShareList.add(accShare);
                }
                
            }
        }
        //system.debug('DEBUG:insertSharelist '+insertShareList);
        system.debug('DEBUG:isnertTeamList'+insertTeamList);
        if(insertTeamList != null && !insertTeamList.isEmpty()){
            insert insertTeamList;
        }
        
        if(accountShareJSONList != null && !accountShareJSONList.isEmpty() && !System.isBatch()){
            doFutureCall(accountShareJSONList);
        }
        //insert insertShareList;
        PageReference pg = new PageReference('/'+accountId);
        //pg.setRedirect(true);
        return redirect();
        
    }    
    @future 
    static void doFutureCall(List<String> accountShareJSONList){
        List<AccountShare> accShareList = new List<AccountShare>();
        for(String str: accountShareJSONList){
            AccountShare acc =  (AccountShare)JSON.deserialize(str, AccountShare.class);
            accShareList.add(acc);
        }
        if(accShareList != null && !accShareList.isEmpty()){
             
            Database.SaveResult[] srshareList = Database.insert(accShareList,false);
            for (Database.SaveResult sr : srshareList) {
                if (!sr.isSuccess()) {            
                    for(Database.Error err : sr.getErrors()) {
                        System.debug('Share records failed with following errors '+err.getMessage());                                
                    }
                }                     
            }
        }    
        
                    
    }
    // Deletes all the extra accountteam members which are extras in location accounts
    /*public static List<AccountTeamMember> deleteExtraRecs(Set<Id> accIdSet, Set<Id> accTeamIdSet){
        
        if(accIdSet.isEmpty() && accTeamIdSet.isEmpty()){
            return null;
        }
        List<AccountTeamMember> accTeamLocDelList = [select id, userid 
                                                           from AccountTeamMember 
                                                           where accountid IN : accIdSet 
                                                           AND userid NOT IN :accTeamIdSet];
        system.debug('DEBUG:acc team location List '+accTeamLocDelList);
        delrecs = accTeamLocDelList.size();
        
        if(!accTeamLocDelList.isEmpty() && accTeamLocDelList != null){
            return accTeamLocDelList;
        }
        else{
            return accTeamLocDelList;
        }
    }*/
    // Gets the delta from the first account and check if anything have to be removed from the account team map
    public static Map<Id, AccountTeamMember> checkDelta(Id accId, Map<Id, AccountTeamMember> accTeamMap){
        if(accId == null && accTeamMap.isEmpty()){    
            return null;
        }
       
        List<AccountTeamMember> accTeammemberList = [select id, 
                                                     userid 
                                                     from AccountTeamMember
                                                     where accountid  = : accId ];
        system.debug('DEBUG:account team member List '+accTeammemberList);
        if(accTeammemberList != null){
            for(AccountTeamMember acct : accTeammemberList){

                if(accTeamMap.keySet().contains(acct.userId)){
                    accTeamMap.remove(acct.userid);
                }          
            }            
        }    
        system.debug('DEBUG:accTeamMap in delta '+accTeamMap);
        return accTeamMap;
    }
    // Gets all the share records of each teammember along with the access
    public static Map<Id,AccessLevel> getSharerecords(Id accId, Set<Id> acTeamsIdSet){
        system.debug('DEBUG:acTeamIdSet'+acTeamsIdSet);
        system.debug('DEBUG:accid'+accId);
        List<AccountShare> accShareList =  [select id ,
                                                accountid,
                                                userorgroupId , 
                                                accountaccesslevel,
                                                opportunityaccesslevel,
                                                caseaccesslevel,
                                                contactaccesslevel 
                                                from AccountShare 
                                                where userorgroupid IN : acTeamsIdSet and accountid = : accId];
            
            Map<Id,AccessLevel> accesslevelMap = new Map<Id, AccessLevel>(); // Key is the userId and Values is a wrapper which has all access levels
            
            for(AccountShare accShare : accShareList ){
                //wrpList.add(new AccessLevel(accShare.AccountAccessLevel, accShare.ContactAccessLevel,accShare.OpportunityAccessLevel,accShare.caseAccessLevel));
                accesslevelMap.put(accshare.userorgroupid, new AccessLevel(accShare.AccountAccessLevel, accShare.ContactAccessLevel,accShare.OpportunityAccessLevel,accShare.caseAccessLevel));
                //wrpList = new List<AccessLevel>();
            }
        system.debug('DEBUG:accessLevelMap '+accesslevelMap);
        return     accesslevelMap;
    }

    public class AccessLevel{
       public String accLevel;
       public String oppLevel;
       public String conLevel;
       public String caslevel;
        
        
        public AccessLevel(String accountaccessLevel, String contactAccessLevel, String opportunityaccessLvel,String caseAccesslevel){
            this.accLevel = accountaccessLevel ;
            this.conLevel = contactAccessLevel ;
            this.oppLevel = opportunityaccessLvel;
            this.casLevel = caseAccesslevel ;   
        }    
    }
    public PageReference rediRect(){
        
        PageReference pg =  new PageReference('/'+accountid);
        pg.setRedirect(true);
        return pg;
    }
    public void runBatch(Set<Id> accIdSet, 
                         Id accid, Map<Id,
                         AccountTeamMember> accTmMap, 
                         List<AccountTeamMember> accTeamDelList ){
                             
        RefreshAccountTeamBatch rAccTeam = new RefreshAccountTeamBatch(accIdSet,accid,accTmMap,accTeamDelList);
        Database.executeBatch(rAccTeam,100);
    }
    
}
Hi,
     I am getting following Issue when i opening Patients in Health Cloud. I have Installed one month free trail version managed package in my org. Please some help me how to resolve this.
"Something's not quite right. Try your action again, and if the issue continues, contact your administrator for help"

Thanks,
Mohan
Hi,
      I have seen that health cloud is available only for Enterprise, unlimited and proffessional editions only how do we practice health cloud in developer edition. Can any one share the trailhead modules and referenses. If we have possibility to install the health cloud in DE please suggest how do we install and use it.

Thanks,
Ram