• Shruthi Vasudeva 7
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi Master developers,
  I am an Admin at a non-profit with newbie to development and need your help! I am trying to deploy a small change from Sandbox to Production , but faced with 'dependent class is invalid and needs recompilation' for all my Apex classes. The change I did was - on a Schedulable batch job ,I removed the insert statement from Finish method to the execute method as I was getting the system limit exception DML rows >10001 (old code , but may be we have too many records now).

My code below -
global void checkCollege(ID college,ID studentID){
        CommunitiesUserPermissionService.ContactShareMatch existingContactSharingRule = null;
        if(existingGroupSharingRulesMap.get(groupMap.get('grp_' + college).Id) != null) {
            existingContactSharingRule = existingGroupSharingRulesMap.get(groupMap.get('grp_' + college).Id).get(studentID);
        }
        
        if (existingContactSharingRule == null) {
            system.debug('making sharing rule');
            ContactShare cs = new ContactShare();
            cs.contactAccessLevel = 'Edit';
            cs.userOrGroupId = groupMap.get('grp_' + college).Id;
            cs.contactId = studentID;
            csList.add(cs);
            CommunitiesUserPermissionService.ContactShareMatch csm = new CommunitiesUserPermissionService.ContactShareMatch();
            csm.matchFound = true;
            csm.rule = cs;
            if(existingGroupSharingRulesMap.get(groupMap.get('grp_' + college).Id) == null) {
                existingGroupSharingRulesMap.put(groupMap.get('grp_' + college).Id, new Map<Id,CommunitiesUserPermissionService.ContactShareMatch>());
            }
            existingGroupSharingRulesMap.get(groupMap.get('grp_' + college).Id).put(studentID, csm);
        } else {
            existingContactSharingRule.matchFound = true;
            System.debug('Existing Rule ' + existingContactSharingRule);
        }
    }
         
    global void execute(Database.BatchableContext BC, List<Application__c> scope) {
        for (Application__c ap : scope) {
            // check school_name and Mid_Year_transfer, each calling the same method.
            // 
            System.debug('School Name: '+ap.School_Name__c+', groupMap get result: '+groupMap.get('grp_' + ap.School_Name__c));
            if (ap.School_Name__c != null && groupMap.get('grp_' + ap.School_Name__c) != null) {
                checkCollege(ap.School_Name__c,ap.student_name__c);
            }
            System.debug('School Name: '+ap.Mid_Year_Transfer_School__c+', groupMap get result: '+
                         groupMap.get('grp_' + ap.Mid_Year_Transfer_School__c));
            if (ap.Mid_Year_Transfer_School__c != null && ap.Mid_Year_Transfer_Status__c == 'Approved' && 
              groupMap.get('grp_' + ap.Mid_Year_Transfer_School__c) != null) {
                checkCollege(ap.Mid_Year_Transfer_School__c,ap.student_name__c);
            }
            
        }
        system.debug('cslist' +  csList);
        if (!csList.isEmpty()) insert csList;     
        cslist.clear();        - Changes here , so that the data is inserted every time the batch is processed and we dont hit the DML limit exception

        
    }

    global void finish(Database.BatchableContext BC) {
        //System.debug(csList);
        //if (! csList.isEmpty()) insert csList;   -Moved this to the execute batch method to resolve the DML system limit exception error
    }




After fixing this , the code ran successfully in Full sandbox but when I deploy I see this error. 
User-added image

Any input is greatly appreciated. 
Thanks!
Hi Master developers,
  I am an Admin at a non-profit with newbie to development and need your help! I am trying to deploy a small change from Sandbox to Production , but faced with 'dependent class is invalid and needs recompilation' for all my Apex classes. The change I did was - on a Schedulable batch job ,I removed the insert statement from Finish method to the execute method as I was getting the system limit exception DML rows >10001 (old code , but may be we have too many records now).

My code below -
global void checkCollege(ID college,ID studentID){
        CommunitiesUserPermissionService.ContactShareMatch existingContactSharingRule = null;
        if(existingGroupSharingRulesMap.get(groupMap.get('grp_' + college).Id) != null) {
            existingContactSharingRule = existingGroupSharingRulesMap.get(groupMap.get('grp_' + college).Id).get(studentID);
        }
        
        if (existingContactSharingRule == null) {
            system.debug('making sharing rule');
            ContactShare cs = new ContactShare();
            cs.contactAccessLevel = 'Edit';
            cs.userOrGroupId = groupMap.get('grp_' + college).Id;
            cs.contactId = studentID;
            csList.add(cs);
            CommunitiesUserPermissionService.ContactShareMatch csm = new CommunitiesUserPermissionService.ContactShareMatch();
            csm.matchFound = true;
            csm.rule = cs;
            if(existingGroupSharingRulesMap.get(groupMap.get('grp_' + college).Id) == null) {
                existingGroupSharingRulesMap.put(groupMap.get('grp_' + college).Id, new Map<Id,CommunitiesUserPermissionService.ContactShareMatch>());
            }
            existingGroupSharingRulesMap.get(groupMap.get('grp_' + college).Id).put(studentID, csm);
        } else {
            existingContactSharingRule.matchFound = true;
            System.debug('Existing Rule ' + existingContactSharingRule);
        }
    }
         
    global void execute(Database.BatchableContext BC, List<Application__c> scope) {
        for (Application__c ap : scope) {
            // check school_name and Mid_Year_transfer, each calling the same method.
            // 
            System.debug('School Name: '+ap.School_Name__c+', groupMap get result: '+groupMap.get('grp_' + ap.School_Name__c));
            if (ap.School_Name__c != null && groupMap.get('grp_' + ap.School_Name__c) != null) {
                checkCollege(ap.School_Name__c,ap.student_name__c);
            }
            System.debug('School Name: '+ap.Mid_Year_Transfer_School__c+', groupMap get result: '+
                         groupMap.get('grp_' + ap.Mid_Year_Transfer_School__c));
            if (ap.Mid_Year_Transfer_School__c != null && ap.Mid_Year_Transfer_Status__c == 'Approved' && 
              groupMap.get('grp_' + ap.Mid_Year_Transfer_School__c) != null) {
                checkCollege(ap.Mid_Year_Transfer_School__c,ap.student_name__c);
            }
            
        }
        system.debug('cslist' +  csList);
        if (!csList.isEmpty()) insert csList;     
        cslist.clear();        - Changes here , so that the data is inserted every time the batch is processed and we dont hit the DML limit exception

        
    }

    global void finish(Database.BatchableContext BC) {
        //System.debug(csList);
        //if (! csList.isEmpty()) insert csList;   -Moved this to the execute batch method to resolve the DML system limit exception error
    }




After fixing this , the code ran successfully in Full sandbox but when I deploy I see this error. 
User-added image

Any input is greatly appreciated. 
Thanks!

I am getting Insufficient privileges issue when visualforce page is accessed on a tab.

Actually, the Visualforce page overrides the standard tab of custom object.

 

I have checked all the custom object permissions on the profile and made sure that Visualforce page and Apex classes are enabled for the profile.

The strange thing is that, when i turn on the View Setup and Configuration permission in the profile, the Visualforce page gets rendered well without any issue.

But i don't want that permission to be turned on.

 

If i turn off, i get the same issue.

 

Any thoughts?

Appreciate any help on this.