• Ankush Dureja
  • NEWBIE
  • 29 Points
  • Member since 2014
  • Salesforce Developer
  • Apttus


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 12
    Replies
For some reason, the test class I've written is failing and I'm not sure why.  It seems to be failing as a result of one of the methods that the trigger calls.  What's weird though is that the method works fine when I'm not running it in test mode (just normally in the sandbox).  So I'm not sure if test mode disables something from working or what it might be, so any insights would be helpful.  Below is the method that the trigger is calling and failing, and the failure seems to be occuring on the third line where the records from the "Case_Assignment_Settings__c" SOQL list gets copied to the single Case_Assignment_Settings__c settings object (the test error is saying "System.ListException: List index out of bounds: 0, Class.caseAssignmentMethods: line 3, column 1,Trigger.caseTriggers: line 18, column 1: []"

Here is the caseAssignmentMethods class:
public class caseAssignmentMethods {
    public static list<Case_Assignment_Settings__c> caseSettings = [SELECT Hours_Until_Stale__c,Assignment_Timeout_Cutoff__c,Case_Match_Set_Size__c,Case_Origin_All_Match_Points__c,Case_Origin_Exact_Match_Points__c,Case_Origin_Exact_Match_Required__c,Location_All_Match_Points__c,Location_Exact_Match_Points__c,Location_Exact_Match_Required__c,Sub_Type_All_Match_Points__c,Sub_Type_Exact_Match_Points__c,Sub_Type_Exact_Match_Required__c,Tier_All_Match_Points__c,Tier_Exact_Match_Points__c,Tier_Exact_Match_Required__c,Times_Skipped_Multiplier__c,Time_Elapsed_Multiplier__c,Type_All_Match_Points__c,Type_Exact_Match_Points__c,Type_Exact_Match_Required__c,User_Type_All_Match_Points__c,User_Type_Exact_Match_Points__c,User_Type_Exact_Match_Required__c FROM Case_Assignment_Settings__c];
    Public static Case_Assignment_Settings__c settings = caseSettings[0];
    Public static Integer samples = settings.Case_Match_Set_Size__c.intValue();
    Public static list<String> filters = new list<String>{'Case_Origin','Location','Sub_Type','Type','Tier','User_Type'};
    public static datetime loginCutoff = System.Now().addHours(0-settings.Assignment_Timeout_Cutoff__c.intValue());
    public static list<Group> groups = [SELECT Id FROM Group WHERE Type = 'Queue' AND Name = 'Unassigned Queue'];
    public static Id uq = groups.get(0).Id;

    public static void sendToUnassignedQueue(list<Case> casesNeedingUQ){
        for(Case c : casesNeedingUQ){
            c.OwnerId = uq;
        }
    }
    
    public static void reassignStaleCases(){
        list<Case> processed = new list<Case>();
        for(Case c : [SELECT Id, OwnerId from Case where Status = 'New' AND Hours_Since_Last_Modified__c > :settings.Hours_Until_Stale__c]){
            Case nc = new Case();
            nc.Id = c.Id;
            nc.OwnerId = uq;
            processed.add(nc);
        }
		update processed;
    }
    
	public static void assignCases(){
		map<Id,map<String,Integer>> scores = new map<Id,Map<String,Integer>>();
        map<Integer,Integer> keys = new map<Integer,Integer>();
        list<Case> cases = new list<Case>();
        list<Case> processed = new list<Case>();
        Integer totCases = 0;
        Boolean process = false;
        Boolean query = true;
        System.debug('samples: '+samples);

        for(User u : [SELECT Id, Name, Email, Type__c, Sub_Type__c, User_Type__c, Case_Origin__c, Tier__c, Location__c, Profile.Name, LastLoginDate FROM User WHERE LastLoginDate != null AND LastLoginDate > :loginCutoff AND Id NOT IN (SELECT OwnerId FROM CASE WHERE (Status = 'In Progress' OR Status = 'New') AND OwnerId != null) ORDER BY LastLoginDate DESC NULLS LAST]){
            
            String finalQuery = buildCaseQuery(u);
            cases = Database.query(finalQuery);
            totCases = cases.size();
            System.debug('totCases: '+totCases);
            if(totCases != 0){
                process=true;
            }
            System.debug('process: '+process);
            if(process){
                Integer i = 0;
                Integer topIdIter = -1;
                Double topScore = -1;
                while(i < samples && i < totCases){
                    Case c = cases.get(i);
                    System.debug('Case Origin: '+c.Id);
                    Double curScore = compareFields(c,u);
                    System.debug('curScore: '+curScore);
                    if(curScore >= 0 && curScore > topScore){
                        topScore = curScore;
                        topIdIter = i;
                    }
                    i++;
                }
                i = 0;
                if(topIdIter >= 0){
                    Boolean finalize = true;
                    while(i <= topIdIter && finalize && i<totCases){
                        if(i == topIdIter){
                            cases[i].inProcess__c = false;
                            cases[i].OwnerId = u.Id;
                            cases[i].Assignment_Points__c = topScore;
                            processed.add(cases.remove(i));
                            totCases--;
                            finalize = false;
                        }
                        else{
                            Integer ts = cases.get(i).Times_Skipped__c.intValue();
                            cases[i].Times_Skipped__c = ts+1;
                            cases[i].inProcess__c = true;
                        }
                        i++;
                    }
                }
                i = 0;
       		 	while(totCases > 0 && cases[i].inProcess__c == true){
            		cases[i].inProcess__c = false;
            		processed.add(cases.remove(i));
            		totCases--;
        		}
        		if(processed.size() > 0){
            		update processed;
        		}
            }
        }
        
    }
	
    public static Double compareFields(Case c,User u){
    	Double curScore = 0;
        Boolean potentialCase = true;
        for(String f : filters){
            String uf = String.valueOf(u.get(f+'__c'));
            String cf = String.valueOf(c.get(f+'__c'));
            Double exactMatchPoints = Double.valueOf(settings.get(f+'_Exact_Match_Points__c'));
            Double allMatchPoints = Double.valueOf(settings.get(f+'_All_Match_Points__c'));
            Boolean exactMatchrequired = Boolean.valueOf(settings.get(f+'_Exact_Match_Required__c'));
            if(uf !=null && cf !=null && uf.contains(cf)){
                curScore += exactMatchPoints;
            }
            else if(uf !=null && cf !=null && !uf.contains('All') && exactMatchrequired){
                potentialCase = false;
            }
            else if(uf !=null && cf !=null && uf.contains('All')){
                curScore += allMatchPoints;
            }
    	}
        curScore += c.Times_Skipped__c != null ? (c.Times_Skipped__c * settings.Times_Skipped_Multiplier__c) : 0;
        curScore += c.Hours_Old__c != null ? (c.Hours_Old__c * settings.Time_Elapsed_Multiplier__c) : 0;
        if(potentialCase){
        	return curScore;
        }
        else{
            return -1;
        }
    }
    
    public static String buildCaseQuery(User u){
        Integer i = 0;
        String queryString = 'SELECT Case_Origin__c,Hours_Old__c,inProcess__c,Assignment_Points__c,CreatedDate,Location__c,OwnerId, Status,Sub_Type__c,Tier__c,Times_Skipped__c,Type__c,User_Type__c FROM Case WHERE Status = \'New\' AND OwnerId = \''+uq+'\'';
            for(String f : filters){
            String ors = '';
            String uf = String.valueOf(u.get(f+'__c'));
            System.debug('Query: '+queryString);
            Boolean exactMatchRequired = Boolean.valueOf(settings.get(f+'_Exact_Match_Required__c'));
            if(uf != null && !uf.contains('All')){
                if(exactMatchRequired){
                    List<String> filterValues = uf.split(';',-2);
                    Integer j = 0;
                    for(String fv : filterValues){
                        if(j==0){
                        	ors+=('('+f+'__c = null OR ('+f+'__c != null AND ('+f+'__c = \''+fv+'\'');
                        }
                        else{
                            ors+=(' OR '+f+'__c = \''+fv+'\'');
                        }
                        j++;
                    }
                    ors+=(')))');
                    if(String.isNotBlank(ors)){
                        queryString+= ' AND '+ors;
                    }
                }
            }
        }
        queryString += ' ORDER BY CreatedDate ASC NULLS LAST LIMIT '+samples;
        System.debug('Query: '+queryString);
        return queryString;
    }
}

Here's the trigger that calls the above methods:

trigger caseTriggers on Case (before update, before insert, after insert, after update) {
    list<Case> cases = trigger.new;
    list<Case> assignedCases = new list<Case>();
    set<Id> userIds = new set<Id>();
    for(Case c : cases){
        userIds.add(c.OwnerId);
    }
    map<Id,User> userMap = new map<Id,User>([SELECT Id, Tier__c FROM User WHERE Id IN :userIds]);
    Boolean caseChanged = false;
    for(Case c : cases){
        if((c.Status == 'New' && (trigger.isInsert && trigger.isBefore || (trigger.isUpdate && trigger.isBefore && c.OwnerId == Trigger.oldMap.get(c.Id).OwnerId))) || (trigger.isUpdate && trigger.isBefore && c.isClosed == false && c.Tier__c != Trigger.oldMap.get(c.Id).Tier__c && !userMap.get(c.OwnerId).Tier__c.contains(c.Tier__c))){
            assignedCases.add(c);
        }
        if(trigger.isAfter){caseChanged = true;
        }
    }
    if(trigger.isBefore && !assignedCases.isEmpty()){
        caseAssignmentMethods.sendToUnassignedQueue(assignedCases);
    }
    if(true==true && triggerValidate.allowCaseUpdate && caseChanged){triggerValidate.allowCaseUpdate = false;caseAssignmentMethods.assignCases();triggerValidate.allowCaseUpdate = true;
    }
}

And lastly, here's my test class:

@isTest 
public class testAllCaseTrigger{

    static testMethod void testInactivityMethod() { 
    List<RecordType> rtypes = [Select Id From RecordType where Name='Person Account' and isActive=true];
    List<Account> accounts = new List<Account>{}; 
    List<Case> cases = new List<Case>{}; 
    
    test.startTest(); 
    
    for(Integer i = 0; i < 1; i++){ 
    Account newAcct = new Account(LastName='TestAcct'+ i,Phone='111',RecordTypeID=rtypes[0].ID);  
    accounts.add(newAcct); 
    } 
    
    insert accounts; 
    
    for(Integer i = 0; i < 1; i++){ 
    Case newCase = new Case(SuppliedName='TestAcct'+ i,Subject='111');  
    cases.add(newCase); 
    } 
    
    insert cases; 
    
    
    test.stopTest(); 
    
    }
    
    static testMethod void testCaseAssignment() {
        list<Profile> profiles = [SELECT Id FROM Profile WHERE Name = 'Service Rep'];
        Id profile = profiles[0].Id;        
        
      	User u = new User();
        u.LastName = 'Test';
        u.FirstName = 'Test';
        u.Email = 'abc13@123.com';
        u.ProfileId = profile;
        u.Tier__c = 'Tier 1';
        u.Username = 'abc13@123.com';
        u.Alias = 'Test1';
        u.CommunityNickname = 'TestNick';
        u.TimeZoneSidKey = 'America/Los_Angeles';
        u.LocaleSidKey = 'en_US';
        u.EmailEncodingKey = 'ISO-8859-1';
        u.LanguageLocaleKey = 'en_US';
        Insert u;
        
        User u2 = new User();
        u2.LastName = 'Test2';
        u2.FirstName = 'Test2';
        u2.Email = 'abcd2@123.com';
        u2.ProfileId = profile;
        u2.Tier__c = 'Tier 2';
        u2.Username = 'abcd2@123.com';
        u2.Alias = 'Test2';
        u2.CommunityNickname = 'TestNick2';
        u2.TimeZoneSidKey = 'America/Los_Angeles';
        u2.LocaleSidKey = 'en_US';
        u2.EmailEncodingKey = 'ISO-8859-1';
        u2.LanguageLocaleKey = 'en_US';
        Insert u2;
        
        test.startTest(); 
        
        Case c = new Case();
        c.OwnerId = u.Id;
      	c.Status = 'New';
      	c.Tier__c = 'Tier 1';
   		Insert c;
        
        c.Status = 'In Progress';
        Update c;
        
        c.Tier__c = 'Tier 2';
        Update c;
        test.stopTest(); 
        
   	}

}

Thanks.

I am trying to implement approval or rejection by email functionality. But I can not use salesforce standard 'Enable Email Approval Response' functionality as approval process is assigned to queue also and salesforce 'Enable Email Approval Response' functionality does not support email response approval when we use queue in our approval process.

So I am trying to use visualforce email template with email service. Can anyone provide some sample code or some other help in implementation as I am not able to figure out how it can be done.

Thanks in advance.

Ankush Dureja
Hi,
Page which will display all accounts in the org, there should be one button for Add Account. On click of this button, popup will ask for account details (Mandatory details only) and after click on submit button this new account will add to DB, go to previous page and previous page also will refresh.




Thanks
KMK
  • October 23, 2018
  • Like
  • 0
Please explain with example.
Hi All
can you please share interview questions and different senarios which ask for experienced sfdc developers
 
Hi,

Please any one can explain me about apex:repeat component in salesforce? where we can use?

regards,
Sain
  • August 11, 2015
  • Like
  • 0
For some reason, the test class I've written is failing and I'm not sure why.  It seems to be failing as a result of one of the methods that the trigger calls.  What's weird though is that the method works fine when I'm not running it in test mode (just normally in the sandbox).  So I'm not sure if test mode disables something from working or what it might be, so any insights would be helpful.  Below is the method that the trigger is calling and failing, and the failure seems to be occuring on the third line where the records from the "Case_Assignment_Settings__c" SOQL list gets copied to the single Case_Assignment_Settings__c settings object (the test error is saying "System.ListException: List index out of bounds: 0, Class.caseAssignmentMethods: line 3, column 1,Trigger.caseTriggers: line 18, column 1: []"

Here is the caseAssignmentMethods class:
public class caseAssignmentMethods {
    public static list<Case_Assignment_Settings__c> caseSettings = [SELECT Hours_Until_Stale__c,Assignment_Timeout_Cutoff__c,Case_Match_Set_Size__c,Case_Origin_All_Match_Points__c,Case_Origin_Exact_Match_Points__c,Case_Origin_Exact_Match_Required__c,Location_All_Match_Points__c,Location_Exact_Match_Points__c,Location_Exact_Match_Required__c,Sub_Type_All_Match_Points__c,Sub_Type_Exact_Match_Points__c,Sub_Type_Exact_Match_Required__c,Tier_All_Match_Points__c,Tier_Exact_Match_Points__c,Tier_Exact_Match_Required__c,Times_Skipped_Multiplier__c,Time_Elapsed_Multiplier__c,Type_All_Match_Points__c,Type_Exact_Match_Points__c,Type_Exact_Match_Required__c,User_Type_All_Match_Points__c,User_Type_Exact_Match_Points__c,User_Type_Exact_Match_Required__c FROM Case_Assignment_Settings__c];
    Public static Case_Assignment_Settings__c settings = caseSettings[0];
    Public static Integer samples = settings.Case_Match_Set_Size__c.intValue();
    Public static list<String> filters = new list<String>{'Case_Origin','Location','Sub_Type','Type','Tier','User_Type'};
    public static datetime loginCutoff = System.Now().addHours(0-settings.Assignment_Timeout_Cutoff__c.intValue());
    public static list<Group> groups = [SELECT Id FROM Group WHERE Type = 'Queue' AND Name = 'Unassigned Queue'];
    public static Id uq = groups.get(0).Id;

    public static void sendToUnassignedQueue(list<Case> casesNeedingUQ){
        for(Case c : casesNeedingUQ){
            c.OwnerId = uq;
        }
    }
    
    public static void reassignStaleCases(){
        list<Case> processed = new list<Case>();
        for(Case c : [SELECT Id, OwnerId from Case where Status = 'New' AND Hours_Since_Last_Modified__c > :settings.Hours_Until_Stale__c]){
            Case nc = new Case();
            nc.Id = c.Id;
            nc.OwnerId = uq;
            processed.add(nc);
        }
		update processed;
    }
    
	public static void assignCases(){
		map<Id,map<String,Integer>> scores = new map<Id,Map<String,Integer>>();
        map<Integer,Integer> keys = new map<Integer,Integer>();
        list<Case> cases = new list<Case>();
        list<Case> processed = new list<Case>();
        Integer totCases = 0;
        Boolean process = false;
        Boolean query = true;
        System.debug('samples: '+samples);

        for(User u : [SELECT Id, Name, Email, Type__c, Sub_Type__c, User_Type__c, Case_Origin__c, Tier__c, Location__c, Profile.Name, LastLoginDate FROM User WHERE LastLoginDate != null AND LastLoginDate > :loginCutoff AND Id NOT IN (SELECT OwnerId FROM CASE WHERE (Status = 'In Progress' OR Status = 'New') AND OwnerId != null) ORDER BY LastLoginDate DESC NULLS LAST]){
            
            String finalQuery = buildCaseQuery(u);
            cases = Database.query(finalQuery);
            totCases = cases.size();
            System.debug('totCases: '+totCases);
            if(totCases != 0){
                process=true;
            }
            System.debug('process: '+process);
            if(process){
                Integer i = 0;
                Integer topIdIter = -1;
                Double topScore = -1;
                while(i < samples && i < totCases){
                    Case c = cases.get(i);
                    System.debug('Case Origin: '+c.Id);
                    Double curScore = compareFields(c,u);
                    System.debug('curScore: '+curScore);
                    if(curScore >= 0 && curScore > topScore){
                        topScore = curScore;
                        topIdIter = i;
                    }
                    i++;
                }
                i = 0;
                if(topIdIter >= 0){
                    Boolean finalize = true;
                    while(i <= topIdIter && finalize && i<totCases){
                        if(i == topIdIter){
                            cases[i].inProcess__c = false;
                            cases[i].OwnerId = u.Id;
                            cases[i].Assignment_Points__c = topScore;
                            processed.add(cases.remove(i));
                            totCases--;
                            finalize = false;
                        }
                        else{
                            Integer ts = cases.get(i).Times_Skipped__c.intValue();
                            cases[i].Times_Skipped__c = ts+1;
                            cases[i].inProcess__c = true;
                        }
                        i++;
                    }
                }
                i = 0;
       		 	while(totCases > 0 && cases[i].inProcess__c == true){
            		cases[i].inProcess__c = false;
            		processed.add(cases.remove(i));
            		totCases--;
        		}
        		if(processed.size() > 0){
            		update processed;
        		}
            }
        }
        
    }
	
    public static Double compareFields(Case c,User u){
    	Double curScore = 0;
        Boolean potentialCase = true;
        for(String f : filters){
            String uf = String.valueOf(u.get(f+'__c'));
            String cf = String.valueOf(c.get(f+'__c'));
            Double exactMatchPoints = Double.valueOf(settings.get(f+'_Exact_Match_Points__c'));
            Double allMatchPoints = Double.valueOf(settings.get(f+'_All_Match_Points__c'));
            Boolean exactMatchrequired = Boolean.valueOf(settings.get(f+'_Exact_Match_Required__c'));
            if(uf !=null && cf !=null && uf.contains(cf)){
                curScore += exactMatchPoints;
            }
            else if(uf !=null && cf !=null && !uf.contains('All') && exactMatchrequired){
                potentialCase = false;
            }
            else if(uf !=null && cf !=null && uf.contains('All')){
                curScore += allMatchPoints;
            }
    	}
        curScore += c.Times_Skipped__c != null ? (c.Times_Skipped__c * settings.Times_Skipped_Multiplier__c) : 0;
        curScore += c.Hours_Old__c != null ? (c.Hours_Old__c * settings.Time_Elapsed_Multiplier__c) : 0;
        if(potentialCase){
        	return curScore;
        }
        else{
            return -1;
        }
    }
    
    public static String buildCaseQuery(User u){
        Integer i = 0;
        String queryString = 'SELECT Case_Origin__c,Hours_Old__c,inProcess__c,Assignment_Points__c,CreatedDate,Location__c,OwnerId, Status,Sub_Type__c,Tier__c,Times_Skipped__c,Type__c,User_Type__c FROM Case WHERE Status = \'New\' AND OwnerId = \''+uq+'\'';
            for(String f : filters){
            String ors = '';
            String uf = String.valueOf(u.get(f+'__c'));
            System.debug('Query: '+queryString);
            Boolean exactMatchRequired = Boolean.valueOf(settings.get(f+'_Exact_Match_Required__c'));
            if(uf != null && !uf.contains('All')){
                if(exactMatchRequired){
                    List<String> filterValues = uf.split(';',-2);
                    Integer j = 0;
                    for(String fv : filterValues){
                        if(j==0){
                        	ors+=('('+f+'__c = null OR ('+f+'__c != null AND ('+f+'__c = \''+fv+'\'');
                        }
                        else{
                            ors+=(' OR '+f+'__c = \''+fv+'\'');
                        }
                        j++;
                    }
                    ors+=(')))');
                    if(String.isNotBlank(ors)){
                        queryString+= ' AND '+ors;
                    }
                }
            }
        }
        queryString += ' ORDER BY CreatedDate ASC NULLS LAST LIMIT '+samples;
        System.debug('Query: '+queryString);
        return queryString;
    }
}

Here's the trigger that calls the above methods:

trigger caseTriggers on Case (before update, before insert, after insert, after update) {
    list<Case> cases = trigger.new;
    list<Case> assignedCases = new list<Case>();
    set<Id> userIds = new set<Id>();
    for(Case c : cases){
        userIds.add(c.OwnerId);
    }
    map<Id,User> userMap = new map<Id,User>([SELECT Id, Tier__c FROM User WHERE Id IN :userIds]);
    Boolean caseChanged = false;
    for(Case c : cases){
        if((c.Status == 'New' && (trigger.isInsert && trigger.isBefore || (trigger.isUpdate && trigger.isBefore && c.OwnerId == Trigger.oldMap.get(c.Id).OwnerId))) || (trigger.isUpdate && trigger.isBefore && c.isClosed == false && c.Tier__c != Trigger.oldMap.get(c.Id).Tier__c && !userMap.get(c.OwnerId).Tier__c.contains(c.Tier__c))){
            assignedCases.add(c);
        }
        if(trigger.isAfter){caseChanged = true;
        }
    }
    if(trigger.isBefore && !assignedCases.isEmpty()){
        caseAssignmentMethods.sendToUnassignedQueue(assignedCases);
    }
    if(true==true && triggerValidate.allowCaseUpdate && caseChanged){triggerValidate.allowCaseUpdate = false;caseAssignmentMethods.assignCases();triggerValidate.allowCaseUpdate = true;
    }
}

And lastly, here's my test class:

@isTest 
public class testAllCaseTrigger{

    static testMethod void testInactivityMethod() { 
    List<RecordType> rtypes = [Select Id From RecordType where Name='Person Account' and isActive=true];
    List<Account> accounts = new List<Account>{}; 
    List<Case> cases = new List<Case>{}; 
    
    test.startTest(); 
    
    for(Integer i = 0; i < 1; i++){ 
    Account newAcct = new Account(LastName='TestAcct'+ i,Phone='111',RecordTypeID=rtypes[0].ID);  
    accounts.add(newAcct); 
    } 
    
    insert accounts; 
    
    for(Integer i = 0; i < 1; i++){ 
    Case newCase = new Case(SuppliedName='TestAcct'+ i,Subject='111');  
    cases.add(newCase); 
    } 
    
    insert cases; 
    
    
    test.stopTest(); 
    
    }
    
    static testMethod void testCaseAssignment() {
        list<Profile> profiles = [SELECT Id FROM Profile WHERE Name = 'Service Rep'];
        Id profile = profiles[0].Id;        
        
      	User u = new User();
        u.LastName = 'Test';
        u.FirstName = 'Test';
        u.Email = 'abc13@123.com';
        u.ProfileId = profile;
        u.Tier__c = 'Tier 1';
        u.Username = 'abc13@123.com';
        u.Alias = 'Test1';
        u.CommunityNickname = 'TestNick';
        u.TimeZoneSidKey = 'America/Los_Angeles';
        u.LocaleSidKey = 'en_US';
        u.EmailEncodingKey = 'ISO-8859-1';
        u.LanguageLocaleKey = 'en_US';
        Insert u;
        
        User u2 = new User();
        u2.LastName = 'Test2';
        u2.FirstName = 'Test2';
        u2.Email = 'abcd2@123.com';
        u2.ProfileId = profile;
        u2.Tier__c = 'Tier 2';
        u2.Username = 'abcd2@123.com';
        u2.Alias = 'Test2';
        u2.CommunityNickname = 'TestNick2';
        u2.TimeZoneSidKey = 'America/Los_Angeles';
        u2.LocaleSidKey = 'en_US';
        u2.EmailEncodingKey = 'ISO-8859-1';
        u2.LanguageLocaleKey = 'en_US';
        Insert u2;
        
        test.startTest(); 
        
        Case c = new Case();
        c.OwnerId = u.Id;
      	c.Status = 'New';
      	c.Tier__c = 'Tier 1';
   		Insert c;
        
        c.Status = 'In Progress';
        Update c;
        
        c.Tier__c = 'Tier 2';
        Update c;
        test.stopTest(); 
        
   	}

}

Thanks.

Hi All,

I need to display a value from MAP<String,Decimal> in VF page. But i am refering two variables as a key in repeat like (Name +'-'+Product name). I am getting error in experrion..,

Here is my VF code:
<apex:pageBlockTable value="{!commProductAgentFinal}" var="r">
                        <apex:column value="{!r.name}">
                            <apex:facet name="header">Carrier Name</apex:facet>
                        </apex:column>  
                        <apex:column value="{!r.Product__r.name}">
                            <apex:facet name="header">Product Name</apex:facet>
                        </apex:column>
                        <apex:column value="{!r.Option__c}">
                            <apex:facet name="header">Option</apex:facet>
                        </apex:column>
                        <apex:column value="{!r.Beginning_Age__c}">
                            <apex:facet name="header">Beg age</apex:facet>
                        </apex:column>
                        <apex:column value="{!r.Ending_Age__c}">
                            <apex:facet name="header">End age</apex:facet>
                        </apex:column>
                        <apex:column value="{!r.Beg_Face_Amount__c}">
                            <apex:facet name="header">Beg Face</apex:facet>
                        </apex:column>
                        <apex:column value="{!r.End_Face_Amount__c}">
                            <apex:facet name="header">End Face</apex:facet>
                        </apex:column>
                        <apex:column value="{!FinalMap[{!r.name}+{!r.Product__r.name}]}">
                            <apex:facet name="header">Total points</apex:facet>
                        </apex:column>          
                    </apex:pageBlockTable>

Controller:
public Map<string,Decimal> FinalMap {get; set;}

Error:Map key r.name-r.Product__r.name not found in map

Error is in expression '{!FinalMap['r.name-r.Product__r.name']}' in component <apex:column> in page commission_schedule

Can anyone help on this ?
I am trying to implement approval or rejection by email functionality. But I can not use salesforce standard 'Enable Email Approval Response' functionality as approval process is assigned to queue also and salesforce 'Enable Email Approval Response' functionality does not support email response approval when we use queue in our approval process.

So I am trying to use visualforce email template with email service. Can anyone provide some sample code or some other help in implementation as I am not able to figure out how it can be done.

Thanks in advance.

Ankush Dureja
Create a custom field cancel__c(checkbox) on sales_Order__c  custom object.
Whenever this checkbox gets checked, a trigger should fire and update the Discount percentage field to 50%.
Why action region tag in visualforce page ? plz any one can explain with suitable example...
  • February 11, 2014
  • Like
  • 0

Hi All,

 

As shown below the  execution of the process order is right  r not?if not so Please do the changes and let me know.

 

Validation

Apex class

Triggers

Workflows

 

Thanks

hi ,

what is OWD in salesforce???

What is the use of that one???

 I can't get any more details.

so please explain briefly.

 

thanks,

Krishna.

On the task there is a WhatId and a WhoId. Sometimes the WhatId is filled in and others have the WhoId filled in. In which situations is one used over the other?

 

Thanks 

  • October 29, 2009
  • Like
  • 1