• akallioWiley
  • NEWBIE
  • 5 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 25
    Replies
In the code below the if statement is checking for a value that is using the OwnerId field on a Custom object to reference a field on the User object. When I use a custom field in the statement, I get the following error message: Invalid field District__c for SObject Name

Here is the code that generated that error:
 
if(contactEval.Owner.District__c == '') {
								approvalReasons.add(BUDGET_LIMIT_EXCEEDED_REASON);
                                itemApprovalReasons.add(BUDGET_LIMIT_EXCEEDED_REASON);
                                requiresProductApproval = true;
                            }

But, if I use a Standard Field, I get no error message. For example: 
 
if(contactEval.Owner.IsActive) {
								approvalReasons.add(BUDGET_LIMIT_EXCEEDED_REASON);
                                itemApprovalReasons.add(BUDGET_LIMIT_EXCEEDED_REASON);
                                requiresProductApproval = true;
                            }

I have tried this for a few different Standard and Custom fields to confirm that it's not these specific fields. 

Any ideas why I can reference a custom field on the User object?
Hello. I wrote this trigger and it has been in  my production environment  for almost 1 year without any problems until yesterday. One of my routine processes is to reassign opportunities when rep Account assignments are changed...I use an ex-Anon script to make these kinds of updates and all of a sudden I am getting an error message that points me to my trigger when execute the script. The things is I can't see how my script would causing the trigger to fire. The script simply updates the OwnerId and TerritoryId fields of the Opportunity object. Although, the trigger is an after update the trigger there is criteria that checks for Stage changes before passing parameters to a class.  My script makes no updates to the stage field. So, I'm hoping some extra eyes could tell me why the trigger is being executed.

So, here is the trigger:

trigger opptyTrigger_EvalSyncController on Opportunity (after update) {
   
   
    if(trigger.isUpdate) {   
       
        Map<Id,Opportunity> courseToOppty = new Map<Id,Opportunity>();
       
        for(Opportunity oppty : trigger.new) {             
                       
            if((oppty.StageName == 'Active' || oppty.StageName == 'Short Stack' || oppty.StageName == 'Probable' ||
                oppty.StageName == 'Won' || oppty.StageName == 'Won Format TBD')
               &&
               (trigger.oldMap.get(oppty.Id).StageName != 'Active' || trigger.oldMap.get(oppty.Id).StageName != 'Short Stack' ||
                trigger.oldMap.get(oppty.Id).StageName != 'Probable' || trigger.oldMap.get(oppty.Id).StageName != 'Won' ||
                trigger.oldMap.get(oppty.Id).StageName != 'Won Format TBD') ) {
               
                    courseToOppty.put(oppty.Course__c,oppty);   
            }
        }
       
         if(!courseToOppty.isEmpty()) {
            coreSynchronizer.sendEvalsToCore(courseToOppty);
        }
    }
}
======================================================================================================================

And here is the script with the error message that follows:

List<Opportunity> upOppties = new List<Opportunity>();
for(Opportunity oppty : [select Id, Name, OwnerId, Owner.Name, TerritoryId, Territory.Name from Opportunity where Owner.Name = 'Andy Kallio' Limit 100]) {
system.debug('Results: '+oppty.Id+' '+oppty.Name+' '+oppty.Territory.name+' '+oppty.Owner.Name);
oppty.OwnerId = '005G0000004NdWEIA0';

oppty.territoryId = '04TA00000004GGfMAM';

upOppties.add(oppty);

}

update upOppties;

==============================================================================================================

Apex script unhandled trigger exception by user/organization: 005G0000002DZlD/00DA0000000YFEv

opptyTrigger_EvalSyncController: execution of AfterUpdate

caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)

Class.coreSynchronizer.sendEvalsToCore: line 13, column 1
Trigger.opptyTrigger_EvalSyncController: line 42, column 1
I have a visualforce page that works fine in Chrome and in Firefox, but does a strange thing in IE. So, far I have confirmed it happens in IE 9 & 10.

The page is basically just a form for entering addresses. In IE when the Save button is clicked the picklist field for State is updated to Null. The controller will not allow the information to be saved without that data...so an error message is displayed on the page. 

I am just looking for some basic advice on where to start with debugging this because I'm an admin that has taught himself to write some apex and visualforce. The is the first time I've had a browser based issue and I'm not sure where to start. I've started to play around witih IE's developer tool...a little overwhelming. 
I created a custom chatter action to create a Case from a custom object. Everythig works fine except for the fact that the Case Assignment rules didn't kick-in. 

My 2 options for assigning the case were to use workflow rules or write a trigger. I went with the trigger because I have 5 and counting assignment rules and I don't want to create a workflow rule for each. 

The trigger works fine too. The issue is that when the trigger is used the resulting ChatterFeedItem is not created....once the user hits 'Submit'  the case is created, but the Chatter post is not created. So, I'm looking for ideas on how to get that chatter post created. 

Here is the trigger's logic:

if(trigger.isInsert && trigger.isAfter) {
       //This will ensure that Case assignments are run even Cases are created through Chatter Actions or through some other service.
       //Fetching the assignment rules on case
       AssignmentRule AR = new AssignmentRule();
     AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
       
       //Creating the DMLOptions for "Assign using active assignment rules" checkbox
       Database.DMLOptions dmlOpts = new Database.DMLOptions();
       dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
      
       Set<Id> newCaseIds = new Set<Id>();
       List<Case> newCases = new List<Case>();
       
       for(Case newCaseId : trigger.new) {
           newCaseIds.add(newCaseId.Id) ;         
       }
       
        for(Case newCase : [select Id from Case where Id IN :newCaseIds]) {
           newCase.setOptions(dmlOpts);        
           newCases.add(newCase);
        }
       
        update newCases;

Hi All. Below is a really simple chatter trigger that I have written to help me with creating cases from chatter posts. It's my first chatter trigger, and I'm getting stumped on the line that is commented out. I can't get that line to compile. It seems that I can't get the FeedItem's Body from the feedcomment. Is my syntax wrong, or is not possible this way?

 

Thanks!

 

 

 

trigger createCaseFromChatter on FeedComment (after insert) {

    for(FeedComment f : trigger.new) {
        if(f.CommentBody.startsWith('!newCase')) {
            Case newCase = new Case(
            	Subject = f.CommentBody,
                //Description = f.FeedItem.Body,
                Origin = 'Chatter',
                RecordtypeId = '012G0000000yArc',
                Status = 'Open'                
            );
            insert newCase;
        }
    }
}

 

Hi All,

I'm having trouble debugging the following line, which is highlighted in code below: 

consCourseCodeMapBig.get(Con.Id).keySet()

for some reason the first value in the set is Null, and the second value is the value I'm expecting to receive. I have confirmed this by testing in UI with the system.assert that you see in the red highlighed section. That system assert returns the following:

Error:

courseRoleTrigger: execution of AfterInsert caused by: System.AssertException: Assertion Failed: Youre here {null, a0FZ0000001sjSzMAI} Class.contactToCourseCodeHandler.saveLogic: line 83, column 1 Class.contactToCourseCodeHandler.newCourseRoleHandler: line 10, column 1 Trigger.courseRoleTrigger: line 20, column 1

 

 

 

I didn't even think it was possible to have a null value in a keySet, and not sure where in my code it would be happening. The section highlighted in blue is where the map is being built. I have used system.asserts there,too and do not find null value there.

 

 

Thanks for any help!

 

 

 

public with sharing class contactToCourseCodeHandler {
    public static void newCourseRoleHandler(Set<Id> newCRs) {
        
        Map<Id,Map<Id,courseCodeWrapper>> contactToCourseCodeBig = createBigCCWMap(newCRS, 'cRole');
        Map<Id,courseCodeWrapper> contactToCourseCodeLittle = createLittleCCWMap(newCRS, 'cRole');
            
        if(!contactToCourseCodeBig.isEmpty()) {
            String reqType = 'Insert/Update';
            String source = 'Course';
            saveLogic(contactToCourseCodeBig,contactToCourseCodeLittle, reqType, source);
        }
    }
    
    public static void deletedCourseRoleHandler(Set<Id> deletedCRs) {
        
        map<Id,Map<Id,courseCodeWrapper>> contactToCourseCodeBig = createBigCCWMap(deletedCRs, 'cRole');        
        map<Id,courseCodeWrapper> contactToCourseCodeLittle = createLittleCCWMap(deletedCRs, 'cRole');
        
        if(!contactToCourseCodeBig.isEmpty()) {
            String reqType = 'Delete';
            String source = 'Course';
            saveLogic(contactToCourseCodeBig,contactToCourseCodeLittle, reqType, source);
        }
    }
    
    public static void updatedCourseRoleHandler() {
    }
    
    public static void evalItemHandler(Set<Id> evalItems) {
   
	    map<Id,Map<Id,courseCodeWrapper>> contactToCourseCodeBig = createBigCCWMap(evalItems, 'eval');
	    map<Id,courseCodeWrapper> contactToCourseCodeLittle = createLittleCCWMap(evalItems, 'eval');
	   
	    if(!contactToCourseCodeBig.isEmpty()) {
	    String reqType = 'Insert/Update';
	    String source = 'Eval';
	    saveLogic(contactToCourseCodeBig,contactToCourseCodeLittle, reqType, source);
	    }
    }
    
    public static void deletedEvalItemHandler(Set<Id> deletedEvalItems) {
   
	    map<Id,Map<Id,courseCodeWrapper>> contactToCourseCodeBig = createBigCCWMap(deletedEvalItems, 'eval');
	    map<Id,courseCodeWrapper> contactToCourseCodeLittle = createLittleCCWMap(deletedEvalItems, 'eval');
	   
	    if(!contactToCourseCodeBig.isEmpty()) {
		    String reqType = 'Delete';
		    String source = 'Eval';
		    saveLogic(contactToCourseCodeBig,contactToCourseCodeLittle, reqType, source);
	    }
   
    }
    
    public static void deletedEvalHandler(Set<Id> evals) {    
   
	    Set<Id> evalItems = new Set<Id>();
	   
	    for(Comp_Item__c ei : [select ID from Comp_Item__c where  Comp__c IN :evals]) {
	    	evalItems.add(ei.Id);
	    }	   
	   
	    map<Id,Map<Id,courseCodeWrapper>> contactToCourseCodeBig = createBigCCWMap(evalItems, 'eval');
	    map<Id,courseCodeWrapper> contactToCourseCodeLittle = createLittleCCWMap(evalItems, 'eval');
	   
	   
	    if(!contactToCourseCodeBig.isEmpty()) {
		    String reqType = 'Delete';
		    String source = 'Eval';
		    saveLogic(contactToCourseCodeBig,contactToCourseCodeLittle, reqType, source);
		}
   
    }    
    
    
    public static void saveLogic(Map<Id,Map<Id,courseCodeWrapper>> consCourseCodeMapBig, Map<Id,courseCodeWrapper> consCourseCodeMapLittle, String triggerType, String source) {
        
        List<Contact_Course_Code__c> ccdUpsert = new List<Contact_Course_Code__c>();
        List<Contact_Course_Code__c> ccdDelete = new List<Contact_Course_Code__c>();
        
        if(triggerType == 'Insert/Update') {
        	for(Contact Con : [Select Id, Course_Code_Count__c, (Select Id, Contact__c, Course_Code__c, CourseRoleCount__c, EvalCount__c from Contact_Course_Code__r) from Contact where Id IN :consCourseCodeMapBig.keySet()]) {
        		if(Con.Course_Code_Count__c == 0) {
        		   for(Id cccId : consCourseCodeMapBig.get(Con.Id).keySet()) { system.assert(false,'Youre here '+consCourseCodeMapBig.get(Con.Id).keySet());
	        			Contact_Course_Code__c newCCC = new Contact_Course_Code__c(
	        				Contact__c = Con.Id,
	        				Course_Code__c = cccId,
	        				CourseRoleCount__c = source == 'Course' ? consCourseCodeMapLittle.get(Con.Id).theCount : 0,
	        				EvalCount__c = source == 'Eval' ? consCourseCodeMapLittle.get(Con.Id).theCount : 0        				
	        			);
        			ccdUpsert.add(newCCC);
        			}
        		}else{
        			for(Contact_Course_Code__c existingCCC : Con.Contact_Course_Code__r) {
        				if(consCourseCodeMapBig.get(Con.Id).containsKey(existingCCC.Course_Code__c)) {
        					existingCCC.CourseRoleCount__c += source == 'Course' ? consCourseCodeMapBig.get(Con.Id).get(existingCCC.Course_Code__c).theCount : 0;
        					existingCCC.EvalCount__c += source == 'Eval' ? consCourseCodeMapBig.get(Con.Id).get(existingCCC.Course_Code__c).theCount : 0;
        					ccdUpsert.add(existingCCC);
        				}       				
        			}
        		}
        	}
        } if(null != ccdUpsert) { 
        	upsert ccdUpsert;
        }
            
       /*if(triggerType == 'Delete') {            
                        
            for(Contact con : [Select Id,Name, Course_Code_Count__c, (Select Id, Contact__c, Course_Code__c, CourseRoleCount__c, Current__c, Primary__c,Total_Association_Count__c,EvalCount__c from Contact_Course_Code__r) from Contact where Id IN: consCourseCodeMapBig.keySet()]) {                
                if(con.Course_Code_Count__c > 0) {
                    for(courseCodeWrapper cdWrap : consCourseCodeMap.get(con.Id) ) {                        
                        for(Contact_Course_Code__c existingCCC1 : Con.Contact_Course_Code__r) {
                            if(conCourseCodeMapBig.get(Con.Id).containsKey(existingCCC1.Course_Code__c)) {                                
                                if(existingCCC1.Total_Association_Count__c > 1) {
                                    existingCCC1.CourseRoleCount__c -= source == 'Course' ? conCourseCodeMapBig.get(Con.Id).get(existingCCC1.Course_Code__c).theCount : 0;  
                                    existingCCC1.EvalCount__c -= source == 'Eval' ? conCourseCodeMapBig.get(Con.Id).get(existingCCC1.Course_Code__c).the : 0;
                                    ccdUpsert.add(existingCCC1);
                                }else{
                                    ccdDelete.add(existingCCC1);
                                }
                            }
                        }
                    }
                    if(ccdUpdate.size() > 0) {
                    update conCourseCodesUpdate.values();
                    }
                    if(ccdDelete.size() > 0) {
                        delete conCourseCodesDel.values();
                    }
                }
            }
        } */   
    }
    
    //uses the triggered CourseRoles to map the Contact Id to CourseCodes...course codes in wrapper class.
    public static Map<Id,Map<Id,courseCodeWrapper>> createBigCCWMap(Set<Id> IDs, String source) {
        
        Map<Id,Map<Id,courseCodeWrapper>> bigMap = new Map<Id,Map<Id,courseCodeWrapper>>();
        Map<Id,courseCodeWrapper> littleMap = new Map<Id,courseCodeWrapper>();
        
        if(source == 'cRole') {                    
          
           for(aggregateResult cr1 : [select Contact__c, Course__r.ACE_Code_4__c,  Count(Id) from Course_Role__c where Id IN: IDs AND Course__r.ACE_Code_4__c != null AND Contact__c != null Group By Rollup (Contact__c,Course__r.ACE_Code_4__c)]) {                
               
               courseCodeWrapper wrappedCourse = new courseCodeWrapper(String.valueOf(cr1.get('Contact__c')),String.valueOf(cr1.get('ACE_Code_4__c')),Integer.valueOf(cr1.get('expr0')),source);
               littleMap.put(wrappedCourse.courseCodeId,wrappedCourse);
               bigMap.put(String.valueOf(cr1.get('Contact__c')),littleMap);
           }           
       
        }  else {
        	for(aggregateResult ei : [select Contact__c,Product__r.ACE_Code_4__c,  Count(Id) from Comp_Item__c where Id IN: Ids AND Product__r.ACE_Code_4__c != null and Contact__c != null Group By Rollup (Contact__c,Product__r.ACE_Code_4__c)]) {
        		
        		courseCodeWrapper wrappedEval = new courseCodeWrapper(String.valueOf(ei.get('Contact__c')), String.valueOf(ei.get('ACE_Code_4__c')), Integer.valueOf(ei.get('expr0')),source);
        		littleMap.put(wrappedEval.courseCodeId,wrappedEval);
        		bigMap.put(String.valueOf(ei.get('Contact__c')),littleMap);
        	} 
        }
		return bigMap; 
    }  
    
    public static Map<Id,courseCodeWrapper> createLittleCCWMap(Set<Id> IDs, String source) {
    	
    	Map<Id,courseCodeWrapper> littleMap = new Map<Id,courseCodeWrapper>();
        
        if(source == 'cRole') {                    
          
           for(aggregateResult cr1 : [select Contact__c, Course__r.ACE_Code_4__c,  Count(Id) from Course_Role__c where Id IN: IDs AND Course__r.ACE_Code_4__c != null AND Contact__c != null Group By Rollup (Contact__c,Course__r.ACE_Code_4__c)]) {                
               
               courseCodeWrapper wrappedCourse = new courseCodeWrapper(String.valueOf(cr1.get('Contact__c')),String.valueOf(cr1.get('ACE_Code_4__c')),Integer.valueOf(cr1.get('expr0')),source);
               littleMap.put(String.valueOf(cr1.get('Contact__c')),wrappedCourse);
           }           
       
        }  else {
        	for(aggregateResult ei : [select Contact__c,Product__r.ACE_Code_4__c,  Count(Id) from Comp_Item__c where Id IN: Ids AND Product__r.ACE_Code_4__c != null and Contact__c != null Group By Rollup (Contact__c,Product__r.ACE_Code_4__c)]) {
        		
        		courseCodeWrapper wrappedEval = new courseCodeWrapper(String.valueOf(ei.get('Contact__c')), String.valueOf(ei.get('ACE_Code_4__c')), Integer.valueOf(ei.get('expr0')),source);
        		littleMap.put(String.valueOf(ei.get('Contact__c')),wrappedEval);
        	} 
        }
		return littleMap; 
    }
    
    public class courseCodeWrapper {
        public Id contactId {get; set;}
        public Id courseCodeId {get; set;}        
        public Integer theCount {get; set;}
        public String source {get; set;}
        
        public courseCodeWrapper(Id conId, Id ccId, Integer elCount,  String wCDSource ) {
            contactId = conId; 
            courseCodeId = ccId;           
            theCount = elCount;
            source = wCDSource;
        }        
    } 
}

 

The method below fails and throws a null pointer exception on the highlighted and only on the highlighted line, which is strange because the highlighted is nearly exactly the same as a line above it that is in a different if/else branch. The other thing that has me scratching my head is that the system.assert(also highlighted) shows me that the variable called 'source'  is not null and has the expected value. So, can anyone spot why I might be getting this error?

 

Thanks!

  public static void saveLogic(Map<Id,List<courseCodeWrapper>> consCourseCodeMap, String triggerType, String source) {
        
        if(triggerType == 'Insert/Update') {            
            List<Contact_Course_Code__c> conCourseCodes = new List<Contact_Course_Code__c>();
                        
            for(Contact con : [Select Id,Name, Course_Code_Count__c, (Select Id, Contact__c, Course_Code__c, CourseRoleCount__c, Current__c, Primary__c, EvalCount__c from Contact_Course_Code__r) from Contact where Id IN: consCourseCodeMap.keySet()]) {
                
                if(con.Course_Code_Count__c == 0) {
	                    for(courseCodeWrapper cc : consCourseCodeMap.get(con.Id)) {
	                        
	                        //Integer currentCount = cc.currentCheck ? 1 : 0;
	                		//Integer primaryCount = cc.PrimaryCheck ? 1 : 0;
	                        
	                        Contact_Course_Code__c newCCC = new Contact_Course_Code__c(
	                    		Contact__c = con.Id,                            
	                        	Course_Code__c = cc.courseCodeId,
	                            CourseRoleCount__c = source == 'Course' ? 1 : 0,
	                            EvalCount__c = source == 'Eval' ? 1 : 0
	                            //Current__c = currentCount,                                    
	                            //Primary__c = primaryCount                            
	                    	);
	                        conCourseCodes.add(newCCC);
	                    }                	
                    insert conCourseCodes;
                } else if(con.Course_Code_Count__c > 0) {
                    for(courseCodeWrapper cdWrap : consCourseCodeMap.get(con.Id) ) {
                        
                        //Integer currentCounter = cdWrap.currentCheck ? 1 : 0;
                        //Integer primaryCounter = cdWrap.primaryCheck ? 1 : 0;
                        
                        for(Contact_Course_Code__c conCD : con.Contact_Course_Code__r) {
                            if(conCD.Course_Code__c == cdWrap.CourseCodeId) {                                
                                conCD.CourseRoleCount__c += source == 'Course' ? 1 : 0;
                                conCD.EvalCount__c += source == 'Eval' ? 1 : 0;
                                //conCD.Current__c += currentCounter;
                                //conCD.Primary__c += primaryCounter;
                                conCourseCodes.add(conCD);
                            }
                        }
                    }
                    update conCourseCodes;
                }
            }
        }
            
        if(triggerType == 'Delete') {
            List<Contact_Course_Code__c> conCourseCodesUpdate = new List<Contact_Course_Code__c>();
            List<Contact_Course_Code__c> conCourseCodesDel = new List<Contact_Course_Code__c>();
                        
            for(Contact con : [Select Id,Name, Course_Code_Count__c, (Select Id, Contact__c, Course_Code__c, CourseRoleCount__c, Current__c, Primary__c,Total_Association_Count__c from Contact_Course_Code__r) from Contact where Id IN: consCourseCodeMap.keySet()]) {
                
                if(con.Course_Code_Count__c > 0) {
                    for(courseCodeWrapper cdWrap : consCourseCodeMap.get(con.Id) ) {
                        
                        //Integer currentCounter = cdWrap.currentCheck ? 1 : 0;
                        //Integer primaryCounter = cdWrap.primaryCheck ? 1 : 0;
                        
                        for(Contact_Course_Code__c conCD : con.Contact_Course_Code__r) {
                            if(conCD.Course_Code__c == cdWrap.CourseCodeId) {                                
                                if(conCD.Total_Association_Count__c > 1) {
                                    conCD.CourseRoleCount__c -= source == 'Course' ? 1 : 0;  //system.assert(false, 'This is your SOURCE: '+source);
                                    conCD.EvalCount__c -= source == 'Eval' ? 1 : 0;
                                    //conCD.Current__c += currentCounter;
                                    //conCD.Primary__c += primaryCounter;
                                    conCourseCodesUpdate.add(conCD);
                                }else{
                                    conCourseCodesDEL.add(conCD);
                                }
                            }
                        }
                    }
                    if(conCourseCodesUpdate.size() > 0) {
                    	update conCourseCodesUpdate;
                    }
                    if(conCourseCodesDel.size() > 0) {
                        delete conCourseCodesDel;
                    }
                }
            }
        }    	
    }

 

I am trying to increment a field based on if/else logic. I'm just starting to get the hang of the ternary operator. So, I wrote the following, but it won't compile. Does anybody know if it's possible to do this, or does it have to go in an if else statement?

 

conCD.CourseRoleCount__c = source == 'Course' ? +=1 : 0; 

I am trying to use a SOSL query where the criteria will be input from a text box on a VF page. I am running into a null pointer exception and struggling to figure out what it is. It is my first time using SOSL. So, I'm hoping the issue will be easy to spot.

 

public with sharing class mergeMaster {

	public string searchString {get; set;}
	public List<resultWrapper> wrappedResults {get; set;}
    
       
    //fired when the Search button is clicked
    public PageReference search() {
    	    	
    	List<List<SObject>> searchList = [FIND :searchString IN ALL FIELDS RETURNING CONTACT (Id, Name, Account.Name Order By Name) ];    	
    	
    	for(Contact reCon : (List<Contact>) searchList[0]) {    		
    		resultWrapper wrCon = new resultWrapper(reCon.Id, reCon.Name, reCon.Account.Name);
    		//system.assert(false,'Results: '+wrCon);
    		wrappedResults.add(wrCon);
    	}
    	
    	return null; 
    }  
  
    
    public class resultWrapper {
        public Id contactID {get; set;}
        public String contactName {get; set;}   
        public String accountName {get; set;}
        public List<SelectOption> masterORchild {get; set;}
        
        public resultWrapper(ID cID, String cName, String aName) {
            contactID = cID;
            contactName = cName;
            accountName = aName;
            this.masterORchild = new List<SelectOption>{new SelectOption('The Master','The Master'),new SelectOption('Merge','Merge')};
        }   
    }

}

 

 

<apex:page sidebar="false" controller="mergeMaster" standardstylesheets="false">
   
    <apex:sectionheader title="Merge Master" />
    
     <apex:form id="theform">
     <apex:pageBlock mode="edit" id="block">
     
     	<apex:pageBlockSection >
        	<apex:pageBlockSectionItem >            
             <apex:panelGroup >
             	<apex:inputText id="searchString" value="{!searchString}"/>
             	<apex:commandButton value="Search" action="{!search}" rerender="block" status="status"/>
             </apex:panelGroup>
        	</apex:pageBlockSectionItem>  
        </apex:pageBlockSection><br/>
        
        <apex:actionStatus id="status" startText="Searching... please wait..."/>
        <apex:pageBlockSection >  
                    
			<apex:pageBlockSection title="Search Results" id="resultsBlock" columns="1">
 			<apex:pageBlockTable value="{!wrappedResults}" var="item" rendered="{!NOT(ISNULL(wrappedResults))}">
   				
   				<apex:column value="{!item.contactName}" headerValue="Contact" width="100"/>
   				<apex:column: value="{!item.accountName}" headerValue="Account" width="200"/>          				
 			</apex:pageBlockTable>
			</apex:pageBlockSection>
        
        </apex:pageBlockSection>            
       
      </apex:pageBlock> 
      </apex:form>  

</apex:page>

 

The class posted below is fed a set of Contact Ids that comes from a trigger on the Task object. We use particular Task record type to track what we call 'Market Development'. A Market Development task contributes towards a total Market Development score for the contact. Therefore we have this class which will add or subtract MD points for a Contact as MD tasks are added or deleted. 

 

My issue is that Total Points are not being subtracted when an MD task is deleted. As I said the class receives a set of contact ids and processes MD points from there by using SOQL to select the Contacts and their MD Tasks. What I have found is that, in after delete trigger context only, the SOQL query that is supposed to get the Contact fails to find the contact. And this where I get stuck. I have put comments in the code below to hopefully help you understand how I am trying to debug this.

 

Any thoughts on why this is happening or a different debugging technique would be great.

public class MarketDevelopmentScorecard {

    public static void updateMarketDevelopmentScorecard(Set<Id> contactIds) {
    	RecordType mdRecordType = RecordTypeUtil.getRecordType('Task', 'Market Development');
    	if (mdRecordType != null) {
            Date recentActivityDate = System.today().addDays(-1095); // 3 years ago
	        
	        List<Task> mdTasks =
	            [select Id,
	                    ActivityDate,
	                    MD_Activity_Type__c,
	                    WhoId
	            from    Task
	            where   WhoId in :contactIds
	                and RecordTypeId = :mdRecordType.Id
	                and ActivityDate >= :recentActivityDate];
	                
            Map<Id, Set<String>> contactMarketDevelopmentActivities = new Map<Id, Set<String>>();
	        for (Task t : mdTasks) {
	        	if (t.MD_Activity_Type__c != null && t.MD_Activity_Type__c != '') {
	                Set<String> mdActivities = contactMarketDevelopmentActivities.get(t.WhoId);
	                if (mdActivities == null) {
	                    mdActivities = new Set<String>();
	                    contactMarketDevelopmentActivities.put(t.WhoId, mdActivities);
	                }
	                mdActivities.add(t.MD_Activity_Type__c);
	        	}
	        }

            List<Market_Development_Rating__c> marketDevelopmentRatings = Market_Development_Rating__c.getAll().values();
            
            for (Id cId : contactIds) {
            	System.debug('JJB contactId: ' + cId);
            }
            
            List<Contact> contacts = 
                [select Id,
                        MD_Total_Points__c,
                        MD_Activities__c
                from    Contact
                where   Id in :contactIds];
            //this system assert shows that I am receiving a contact from the trigger, but that the SOQL query doesn't find it
            //system.assert(false, 'Contacts from Trigger '+contactIds.size()+'Contacts found in database '+contacts.size());
            for (Contact c : contacts) {
            	Decimal totalPoints = 0.0;
            	String activities = '';
                //in after delete context this system assert never gets hit because this for loop never starts because there is nothing in the List contacts
            	//system.assert(false, 'hello!! ');            	
            	Set<String> mdActivities = contactMarketDevelopmentActivities.get(c.Id);
            	if (mdActivities == null) {
            		mdActivities = new Set<String>();
            	}
            	
            	for (Market_Development_Rating__c mdr : marketDevelopmentRatings) {
            		if (mdActivities.contains(mdr.Name)) {
            			totalPoints += mdr.MD_Points__c;
            			if (mdr.Contact_Field_Name__c != null && mdr.Contact_Field_Name__c != '') {
            				c.put(mdr.Contact_Field_Name__c, mdr.MD_Points__c);
            				//system.assert(false, 'the total points are: '+mdr.MD_Points__c);
            			}
            		} else {
                        if (mdr.Contact_Field_Name__c != null && mdr.Contact_Field_Name__c != '') {
                            c.put(mdr.Contact_Field_Name__c, 0.00);
                        }
            		}
            	}

 

 

 

Hi,

 

I'm getting this issue when trying to deploy a trigger for Account and Contact. I'm not sure why this is happening since I'm not touching any of the objects used by Milestone PM. Has anyone encountered this issue before? Any workaround? Thanks!

 

 

 

Failure Message: "System.AssertException: Assertion Failed: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Insert failed. First exception on row 6; first error: LIMIT_EXCEEDED, Maximum per user subscription limit reached.: []: []", Failure Stack Trace: "Class.Milestone1_Task_Trigger_Util...

 

 

 

Hi,

 

When im deploying one premission set with one custom app premission it is not deploying throwing error as :

 


# Deploy Results:
   File Name:    permissionsets/SSR_Holdings_Permission_Set.permissionset
   Full Name:  SSR_Holdings_Permission_Set
   Action:  NO ACTION
   Result:  FAILED
   Problem: Unknown user permission: AllowDeleteDandBCompany

 

Plz Advice