• Ajay Kumar 261
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies
Hi,

My Class:
public static void UpdateDevAmountAndAmountOppty (List<Opportunity> OptyTriggerNewList, Map<Id,Opportunity> OptyTriggerOldMap, String sOperation) { 

    
     Set<Id> oppsIds = new Set<Id>();
     List<Opportunity> renewalOpps = new List<Opportunity>();
     List<Opportunity> OppsList = new List<Opportunity>();    
     for( Opportunity opp : OptyTriggerNewList ) {     
            if(sOperation=='sInsert'){
                if(opp.Dev_Amount__c!=null){
                    Opp.Amount = opp.Dev_Amount__c;                    
                }else if(opp.Amount !=null){
                    Opp.Dev_Amount__c = opp.Amount;                    
                }            
            }
            if(sOperation=='sUpdate' && opp.StageName != 'Solicit: Gift Closed/Received 100%'){
                Opportunity oldOpp = OptyTriggerOldMap.get(opp.Id);
                if(opp.Dev_Amount__c <> null && oldOpp.Dev_Amount__c <> opp.Dev_Amount__c && Opp.Amount <> opp.Dev_Amount__c){
                    Opp.Amount = opp.Dev_Amount__c; 
                }else if(opp.Amount <> null && oldOpp.Amount <> opp.Amount && opp.Dev_Amount__c <> Opp.Amount){
                    Opp.Dev_Amount__c = opp.Amount; 
                }            
            }
        }
	}
Test Class:
static testMethod void myUnitTest() {              
        Test.startTest();
        Opportunity testopp = new Opportunity();
        testopp.name = 'testOpp';
        testopp.Site__c = 'National';
        testopp.Category__c ='New Opportunity';
        testopp.Cohort__c = 'January 2016';
        testopp.CloseDate = System.today()+10;
        testopp.LeadSource = 'Channel Partners';
        testopp.Stagename = 'Identification: 0%';
        testopp.Restriction_picklist__c = 'Unrestricted';
        testopp.Ask_Amount__c = 200;
        testopp.Amount = 1200;
        testopp.Type = 'Individual';       
        insert testopp;
        //Start test
        system.assertequals(1200,testopp.Dev_Amount__c);      
        
       	Opportunity opp= [select id, Stagename, Amount, Dev_Amount__c from Opportunity where id =:testopp.id ];
        opp.Dev_Amount__c = 1500;
        update opp;
        System.debug('opp.Dev_Amount__c '+opp.Dev_Amount__c);
        system.assertequals(1500,opp.Amount);
		Test.stopTest();
        
    }

Issue: I am having issue with assert statement.

16:48:04.0 (948783585)|FATAL_ERROR|System.AssertException: Assertion Failed: Expected: 400, Actual: null Class.yearup_opportunityTriggerHandlerTest.myUnitTest: line 21, column 1 16:48:04.0 (948790277)|FATAL_ERROR|System.AssertException: Assertion Failed: Expected: 400, Actual: null Class.yearup_opportunityTriggerHandlerTest.myUnitTest: line 21, column 1

Can anyone help me what am I missing?

Regards,
Ajay
 
Hi,

Can anyone help me to achieve this below report?

User-added image

I have to show the Record count for each picklist field based on each picklist value.

Regards,
Ajay
<tbody>
                                                               <apex:repeat value="{!wrapList}" var="e">
                                                                  <tr>                                                                                                                          
                                                                      <td>{!e.eng.name}</td>                                                            
                                                                      <td><apex:outputText value="{!e.eng.Learning_Community__r.Name}" id="lc"/></td> 
                                                                      <td> 
                                                                          <apex:selectList value="{!e.selectedLC}" size="1">
                                                                              <apex:actionSupport event="onchange" action="{!refreshPage}" rerender="lc"  />   
                                                                              <apex:selectOptions value="{!e.selectedCLC}"/>                                                                                                                                       
                                                                          </apex:selectList>                                                                
                                                                      </td>  
                                                                      <td><apex:outputText value="{!e.eng.Learning_Community__r.Track__c}" id="track" /></td>  
                                                                      <td> 
                                                                          <apex:selectList id="trackv" value="{!e.selectedNTrack}" size="1">
                                                                           <apex:actionSupport event="onchange" action="{!refreshPage}" rerender="track" />
                                                                              <apex:selectOptions value="{!e.selectedTrack}"/>
                                                                          </apex:selectList>
                                                                      </td>                         
                                                                  </tr>
                                                               </apex:repeat>                                             
                                                        </tbody>

Controller metod:
public void refreshPage(){
     
     for(WrapperClass wr: wrapList){ 
            wr.eng.Learning_Community__r.Track__c = wr.selectedNTrack;              
            wr.eng.Learning_Community__r.Name = lcOptionsMap.get(wr.selectedLC);                         
         }
 }

The problem is:

As you can see in the screenshot, the last record's value is assigned to the first record for some reason. I hink I am doing some silly mistake. 

User-added image
Can any one help me to find the solution please?

Regards,
Ajay
<td> 
  <apex:selectList id="Lcs" value="{!e.selectedLC}" size="1">
    <apex:selectOptions value="{!e.selectedCLC}"/>
    </apex:selectList>                                                                
    </td>

Controller method:
public class WrapperClass{
        public Engagement__c eng {get; set;}
        public List<SelectOption> selectedTrack{get; set;}
        public String selectedNTrack{get; set;}
        public List<SelectOption> selectedCLC{get; set;}
        public id selectedLC{get; set;}
        public WrapperClass(Engagement__c e,List<SelectOption> track, String s,List<SelectOption> clc, id lc){
            selectedTrack = track;
            eng = e;
            selectedNTrack = s;
            selectedCLC = clc;
            selectedLC = lc;
        }
    }
public void getEngagements(){
 
     selectedTrack = '';
     trackOptions = new List<SelectOption>();
     trackOptions.add(new SelectOption('--None--','--None--'));
     Schema.DescribeFieldResult fieldResult = Learning_Community__c.Track__c.getDescribe();
     List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
       for( Schema.PicklistEntry f : ple)
       {
          trackOptions.add(new SelectOption(f.getLabel(), f.getValue()));
       }       
     
        Lcoptions = new List<SelectOption>();
        Lcoptions.add(new SelectOption('--Unassigned---','--Unassigned--'));
        for(Learning_Community__c obj :[SELECT Id, Name FROM Learning_Community__c Where Cohort__c=:selectedCohort  ] )
        {
            Lcoptions.add(new SelectOption(obj.Id,obj.Name));
            System.Debug('Lcoptions '+Lcoptions);
        }
        wrapList = new list<WrapperClass>();
        for(Engagement__c eng : [Select id, Name, Site__c, Learning_Community__c,Cohort__c,Learning_Community__r.Name, Learning_Community__r.Track__c from Engagement__c where (Cohort__c=:selectedCohort OR Site__c=:selectedSite) ]){           
           
            wrapList.add(new WrapperClass(eng,trackOptions,null,Lcoptions,null));
            System.debug('wrapList '+wrapList);
        }
 
 }
 public void updateEngagements(){
 try{
 
     list<Engagement__c> enList=new list<Engagement__c>(); 
     list<Learning_Community__c> lcList=new list<Learning_Community__c>(); 
         
     for(WrapperClass wr: wrapList){      
         if(wr.eng.Learning_Community__c!=null){
         Learning_Community__c e= new Learning_Community__c();
         e.id = wr.eng.Learning_Community__c;        
         e.Track__c = wr.selectedNTrack;        
         lcList.add(e);
         }
         System.debug('I am inside wrapper First '+wr.selectedLC); 
         if(wr.selectedLC!='--Unassigned---'){  
         Engagement__c en= new Engagement__c();
         en.id = wr.eng.Id; 
         en.Learning_Community__c= wr.selectedLC; 
         enList.add(en);
         }
                      
     }     
     update lcList;
     //update enList;
     
     }
     catch(exception e){
     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value ' +e.getMessage()));
     }    
 }
 
 public class WrapperClass{
        public Engagement__c eng {get; set;}
        public List<SelectOption> selectedTrack{get; set;}
        public String selectedNTrack{get; set;}
        public List<SelectOption> selectedCLC{get; set;}
        public id selectedLC{get; set;}
        public WrapperClass(Engagement__c e,List<SelectOption> track, String s,List<SelectOption> clc, id lc){
            selectedTrack = track;
            eng = e;
            selectedNTrack = s;
            selectedCLC = clc;
            selectedLC = lc;
        }
    }

When I select the option "Name" from the drop down, I am expecting id to be passed to the controller, however I am not getting the id to the relevant name.

I am getting this error:
Warning:
Please enter value Invalid id: --Unassigned---

Regards,
Ajay
Hi,

I have strange issue, which I am not able to figure out. 
<div class="modal-footer"> 
                                        
                                        <apex:commandButton styleclass="btn btn-primary" value="Update Records" action="{!updateEngagements}" rerender="datePanelContainer"   />
                                        
                                    </div>
                                    <apex:outputPanel id="datePanelContainer">
                                    <table class="table table-hover">
                                                  <thead>
                                                    <tr>
                                                      <th>Student Engagement</th>
                                                      <th>Learning Community</th>
                                                      <!--<th>New LC</th>-->
                                                      <th>Current Track</th>
                                                      <th>New Track</th>
                                                    </tr>
                                                  </thead>
                                                  <tbody>
                                                     <apex:repeat value="{!wrapList}" var="e">
                                                        <tr>
                                                            <td>{!e.eng.name}</td>                                                            
                                                            <td>{!e.eng.Learning_Community__r.Name}</td>  
                                                            <!--
                                                            <td> 
                                                                <apex:selectList id="Lcs" value="{!e.selectedLC}" size="1">
                                                                    <apex:selectOptions value="{!e.selectedCLC}"/>
                                                                </apex:selectList>
                                                            </td>
                                                            -->
                                                           
                                                            <td>{!e.eng.Learning_Community__r.Track__c}</td>  
                                                            <td> 
                                                                <apex:selectList id="countries" value="{!e.selectedNTrack}" size="1">
                                                                    <apex:selectOptions value="{!e.selectedTrack}"/>
                                                                </apex:selectList>
                                                           </td>                         
                                                        </tr>
                                                    </apex:repeat>                                             
                                                  </tbody>
                                                </table>                                       
                                  </apex:outputPanel>

The highihlighted and bold <td> tag is causing some issue. If I enable this tag my command button is not invoking the controller method. It is not even showing debug statements.

What could be the reason? 

Any help appreciated.

Reagrds,
Ajay
Hi,

I have a method which will update a field on contact record. As you can see the code below, this method runs on before trugger on contact and then it will update the Merchant Score field. It is is working fine when I update in the UI. However it is not working when I do the bulk update using dataloader and informatica load. it is updating only few records. 

Scenario1: I tried updating 209 records without bulk API, and it worked only for 193 records.
Scenario2: I tried updating 100 records with bulk API, and all of them are success.
Scenario3: I tried updating 150 records with bulk API, and all of them are success.
Scenario4: I tried with 200 records with bulk API, however only 100 got updated.

There is no consistency in the output. Can anyone help me to resolve this?

public static void contactMSScoreUpdate(List<Contact> ContactTriggerList,Map<Id,Contact> OldContactTriggerMap){
 
           for(Contact c : ContactTriggerList){
                      Contact con= OldContactTriggerMap.get(c.Id);
                     if(c.Score_Merchant__c != null&&c.Score_Merchant__c!=con.Score_Merchant__c&&c.score_profile__c!=null){  
                             c.Score_Merchant__c = c.score_profile__c+c.Score_Merchant__c.right(1);
                             system.debug(' c.Score_Merchant__c '+ c.Score_Merchant__c );
                         
                     }
                    
          }
  }

Regards,
Ajay
Hi,

Can anyone suggest me a better formula? This is working fine, however I wanted to see if I get a better formula as it is lengthy one.

CASE( MS_Score__c ,
"0",Profile_Score__c +MS_Score__c,
"1",Profile_Score__c +MS_Score__c,
"2",Profile_Score__c +MS_Score__c,
"3",Profile_Score__c +MS_Score__c,
"4",Profile_Score__c +MS_Score__c,
"A0",Profile_Score__c +RIGHT(MS_Score__c,1),
"A1",Profile_Score__c +RIGHT(MS_Score__c,1),
"A2",Profile_Score__c +RIGHT(MS_Score__c,1),
"A3",Profile_Score__c +RIGHT(MS_Score__c,1),
"A4",Profile_Score__c +RIGHT(MS_Score__c,1),
"B1",Profile_Score__c +RIGHT(MS_Score__c,1),
"B2",Profile_Score__c +RIGHT(MS_Score__c,1),
"B3",Profile_Score__c +RIGHT(MS_Score__c,1),
"B4",Profile_Score__c +RIGHT(MS_Score__c,1),
"C0",Profile_Score__c +RIGHT(MS_Score__c,1),
"C1",Profile_Score__c +RIGHT(MS_Score__c,1),
"C2",Profile_Score__c +RIGHT(MS_Score__c,1),
"C3",Profile_Score__c +RIGHT(MS_Score__c,1),
"C4",Profile_Score__c +RIGHT(MS_Score__c,1),
"D1",Profile_Score__c +RIGHT(MS_Score__c,1),
"D2",Profile_Score__c +RIGHT(MS_Score__c,1),
"D3",Profile_Score__c +RIGHT(MS_Score__c,1),
"D4",Profile_Score__c +RIGHT(MS_Score__c,1),
"E0",Profile_Score__c +RIGHT(MS_Score__c,1),
"E1",Profile_Score__c +RIGHT(MS_Score__c,1),
"E2",Profile_Score__c +RIGHT(MS_Score__c,1),
"E3",Profile_Score__c +RIGHT(MS_Score__c,1),
"E4",Profile_Score__c +RIGHT(MS_Score__c,1),
"U0",Profile_Score__c +RIGHT(MS_Score__c,1),
"U1",Profile_Score__c +RIGHT(MS_Score__c,1),
"U2",Profile_Score__c +RIGHT(MS_Score__c,1),
"U3",Profile_Score__c +RIGHT(MS_Score__c,1),
"U4",Profile_Score__c +RIGHT(MS_Score__c,1),
""
)
Regards,
Ajay
Hi,

Can anyone suggest me a better formula? This is working fine, however I wanted to see if I get a better formula as it is lengthy one.

CASE( MS_Score__c ,
"0",Profile_Score__c +MS_Score__c,
"1",Profile_Score__c +MS_Score__c,
"2",Profile_Score__c +MS_Score__c,
"3",Profile_Score__c +MS_Score__c,
"4",Profile_Score__c +MS_Score__c,
"A0",Profile_Score__c +RIGHT(MS_Score__c,1),
"A1",Profile_Score__c +RIGHT(MS_Score__c,1),
"A2",Profile_Score__c +RIGHT(MS_Score__c,1),
"A3",Profile_Score__c +RIGHT(MS_Score__c,1),
"A4",Profile_Score__c +RIGHT(MS_Score__c,1),
"B1",Profile_Score__c +RIGHT(MS_Score__c,1),
"B2",Profile_Score__c +RIGHT(MS_Score__c,1),
"B3",Profile_Score__c +RIGHT(MS_Score__c,1),
"B4",Profile_Score__c +RIGHT(MS_Score__c,1),
"C0",Profile_Score__c +RIGHT(MS_Score__c,1),
"C1",Profile_Score__c +RIGHT(MS_Score__c,1),
"C2",Profile_Score__c +RIGHT(MS_Score__c,1),
"C3",Profile_Score__c +RIGHT(MS_Score__c,1),
"C4",Profile_Score__c +RIGHT(MS_Score__c,1),
"D1",Profile_Score__c +RIGHT(MS_Score__c,1),
"D2",Profile_Score__c +RIGHT(MS_Score__c,1),
"D3",Profile_Score__c +RIGHT(MS_Score__c,1),
"D4",Profile_Score__c +RIGHT(MS_Score__c,1),
"E0",Profile_Score__c +RIGHT(MS_Score__c,1),
"E1",Profile_Score__c +RIGHT(MS_Score__c,1),
"E2",Profile_Score__c +RIGHT(MS_Score__c,1),
"E3",Profile_Score__c +RIGHT(MS_Score__c,1),
"E4",Profile_Score__c +RIGHT(MS_Score__c,1),
"U0",Profile_Score__c +RIGHT(MS_Score__c,1),
"U1",Profile_Score__c +RIGHT(MS_Score__c,1),
"U2",Profile_Score__c +RIGHT(MS_Score__c,1),
"U3",Profile_Score__c +RIGHT(MS_Score__c,1),
"U4",Profile_Score__c +RIGHT(MS_Score__c,1),
""
)
Regards,
Ajay
<tbody>
                                                               <apex:repeat value="{!wrapList}" var="e">
                                                                  <tr>                                                                                                                          
                                                                      <td>{!e.eng.name}</td>                                                            
                                                                      <td><apex:outputText value="{!e.eng.Learning_Community__r.Name}" id="lc"/></td> 
                                                                      <td> 
                                                                          <apex:selectList value="{!e.selectedLC}" size="1">
                                                                              <apex:actionSupport event="onchange" action="{!refreshPage}" rerender="lc"  />   
                                                                              <apex:selectOptions value="{!e.selectedCLC}"/>                                                                                                                                       
                                                                          </apex:selectList>                                                                
                                                                      </td>  
                                                                      <td><apex:outputText value="{!e.eng.Learning_Community__r.Track__c}" id="track" /></td>  
                                                                      <td> 
                                                                          <apex:selectList id="trackv" value="{!e.selectedNTrack}" size="1">
                                                                           <apex:actionSupport event="onchange" action="{!refreshPage}" rerender="track" />
                                                                              <apex:selectOptions value="{!e.selectedTrack}"/>
                                                                          </apex:selectList>
                                                                      </td>                         
                                                                  </tr>
                                                               </apex:repeat>                                             
                                                        </tbody>

Controller metod:
public void refreshPage(){
     
     for(WrapperClass wr: wrapList){ 
            wr.eng.Learning_Community__r.Track__c = wr.selectedNTrack;              
            wr.eng.Learning_Community__r.Name = lcOptionsMap.get(wr.selectedLC);                         
         }
 }

The problem is:

As you can see in the screenshot, the last record's value is assigned to the first record for some reason. I hink I am doing some silly mistake. 

User-added image
Can any one help me to find the solution please?

Regards,
Ajay
<td> 
  <apex:selectList id="Lcs" value="{!e.selectedLC}" size="1">
    <apex:selectOptions value="{!e.selectedCLC}"/>
    </apex:selectList>                                                                
    </td>

Controller method:
public class WrapperClass{
        public Engagement__c eng {get; set;}
        public List<SelectOption> selectedTrack{get; set;}
        public String selectedNTrack{get; set;}
        public List<SelectOption> selectedCLC{get; set;}
        public id selectedLC{get; set;}
        public WrapperClass(Engagement__c e,List<SelectOption> track, String s,List<SelectOption> clc, id lc){
            selectedTrack = track;
            eng = e;
            selectedNTrack = s;
            selectedCLC = clc;
            selectedLC = lc;
        }
    }
public void getEngagements(){
 
     selectedTrack = '';
     trackOptions = new List<SelectOption>();
     trackOptions.add(new SelectOption('--None--','--None--'));
     Schema.DescribeFieldResult fieldResult = Learning_Community__c.Track__c.getDescribe();
     List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
       for( Schema.PicklistEntry f : ple)
       {
          trackOptions.add(new SelectOption(f.getLabel(), f.getValue()));
       }       
     
        Lcoptions = new List<SelectOption>();
        Lcoptions.add(new SelectOption('--Unassigned---','--Unassigned--'));
        for(Learning_Community__c obj :[SELECT Id, Name FROM Learning_Community__c Where Cohort__c=:selectedCohort  ] )
        {
            Lcoptions.add(new SelectOption(obj.Id,obj.Name));
            System.Debug('Lcoptions '+Lcoptions);
        }
        wrapList = new list<WrapperClass>();
        for(Engagement__c eng : [Select id, Name, Site__c, Learning_Community__c,Cohort__c,Learning_Community__r.Name, Learning_Community__r.Track__c from Engagement__c where (Cohort__c=:selectedCohort OR Site__c=:selectedSite) ]){           
           
            wrapList.add(new WrapperClass(eng,trackOptions,null,Lcoptions,null));
            System.debug('wrapList '+wrapList);
        }
 
 }
 public void updateEngagements(){
 try{
 
     list<Engagement__c> enList=new list<Engagement__c>(); 
     list<Learning_Community__c> lcList=new list<Learning_Community__c>(); 
         
     for(WrapperClass wr: wrapList){      
         if(wr.eng.Learning_Community__c!=null){
         Learning_Community__c e= new Learning_Community__c();
         e.id = wr.eng.Learning_Community__c;        
         e.Track__c = wr.selectedNTrack;        
         lcList.add(e);
         }
         System.debug('I am inside wrapper First '+wr.selectedLC); 
         if(wr.selectedLC!='--Unassigned---'){  
         Engagement__c en= new Engagement__c();
         en.id = wr.eng.Id; 
         en.Learning_Community__c= wr.selectedLC; 
         enList.add(en);
         }
                      
     }     
     update lcList;
     //update enList;
     
     }
     catch(exception e){
     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value ' +e.getMessage()));
     }    
 }
 
 public class WrapperClass{
        public Engagement__c eng {get; set;}
        public List<SelectOption> selectedTrack{get; set;}
        public String selectedNTrack{get; set;}
        public List<SelectOption> selectedCLC{get; set;}
        public id selectedLC{get; set;}
        public WrapperClass(Engagement__c e,List<SelectOption> track, String s,List<SelectOption> clc, id lc){
            selectedTrack = track;
            eng = e;
            selectedNTrack = s;
            selectedCLC = clc;
            selectedLC = lc;
        }
    }

When I select the option "Name" from the drop down, I am expecting id to be passed to the controller, however I am not getting the id to the relevant name.

I am getting this error:
Warning:
Please enter value Invalid id: --Unassigned---

Regards,
Ajay
Hi,

I have strange issue, which I am not able to figure out. 
<div class="modal-footer"> 
                                        
                                        <apex:commandButton styleclass="btn btn-primary" value="Update Records" action="{!updateEngagements}" rerender="datePanelContainer"   />
                                        
                                    </div>
                                    <apex:outputPanel id="datePanelContainer">
                                    <table class="table table-hover">
                                                  <thead>
                                                    <tr>
                                                      <th>Student Engagement</th>
                                                      <th>Learning Community</th>
                                                      <!--<th>New LC</th>-->
                                                      <th>Current Track</th>
                                                      <th>New Track</th>
                                                    </tr>
                                                  </thead>
                                                  <tbody>
                                                     <apex:repeat value="{!wrapList}" var="e">
                                                        <tr>
                                                            <td>{!e.eng.name}</td>                                                            
                                                            <td>{!e.eng.Learning_Community__r.Name}</td>  
                                                            <!--
                                                            <td> 
                                                                <apex:selectList id="Lcs" value="{!e.selectedLC}" size="1">
                                                                    <apex:selectOptions value="{!e.selectedCLC}"/>
                                                                </apex:selectList>
                                                            </td>
                                                            -->
                                                           
                                                            <td>{!e.eng.Learning_Community__r.Track__c}</td>  
                                                            <td> 
                                                                <apex:selectList id="countries" value="{!e.selectedNTrack}" size="1">
                                                                    <apex:selectOptions value="{!e.selectedTrack}"/>
                                                                </apex:selectList>
                                                           </td>                         
                                                        </tr>
                                                    </apex:repeat>                                             
                                                  </tbody>
                                                </table>                                       
                                  </apex:outputPanel>

The highihlighted and bold <td> tag is causing some issue. If I enable this tag my command button is not invoking the controller method. It is not even showing debug statements.

What could be the reason? 

Any help appreciated.

Reagrds,
Ajay
Hi,

I have a method which will update a field on contact record. As you can see the code below, this method runs on before trugger on contact and then it will update the Merchant Score field. It is is working fine when I update in the UI. However it is not working when I do the bulk update using dataloader and informatica load. it is updating only few records. 

Scenario1: I tried updating 209 records without bulk API, and it worked only for 193 records.
Scenario2: I tried updating 100 records with bulk API, and all of them are success.
Scenario3: I tried updating 150 records with bulk API, and all of them are success.
Scenario4: I tried with 200 records with bulk API, however only 100 got updated.

There is no consistency in the output. Can anyone help me to resolve this?

public static void contactMSScoreUpdate(List<Contact> ContactTriggerList,Map<Id,Contact> OldContactTriggerMap){
 
           for(Contact c : ContactTriggerList){
                      Contact con= OldContactTriggerMap.get(c.Id);
                     if(c.Score_Merchant__c != null&&c.Score_Merchant__c!=con.Score_Merchant__c&&c.score_profile__c!=null){  
                             c.Score_Merchant__c = c.score_profile__c+c.Score_Merchant__c.right(1);
                             system.debug(' c.Score_Merchant__c '+ c.Score_Merchant__c );
                         
                     }
                    
          }
  }

Regards,
Ajay
Hi,

Can anyone suggest me a better formula? This is working fine, however I wanted to see if I get a better formula as it is lengthy one.

CASE( MS_Score__c ,
"0",Profile_Score__c +MS_Score__c,
"1",Profile_Score__c +MS_Score__c,
"2",Profile_Score__c +MS_Score__c,
"3",Profile_Score__c +MS_Score__c,
"4",Profile_Score__c +MS_Score__c,
"A0",Profile_Score__c +RIGHT(MS_Score__c,1),
"A1",Profile_Score__c +RIGHT(MS_Score__c,1),
"A2",Profile_Score__c +RIGHT(MS_Score__c,1),
"A3",Profile_Score__c +RIGHT(MS_Score__c,1),
"A4",Profile_Score__c +RIGHT(MS_Score__c,1),
"B1",Profile_Score__c +RIGHT(MS_Score__c,1),
"B2",Profile_Score__c +RIGHT(MS_Score__c,1),
"B3",Profile_Score__c +RIGHT(MS_Score__c,1),
"B4",Profile_Score__c +RIGHT(MS_Score__c,1),
"C0",Profile_Score__c +RIGHT(MS_Score__c,1),
"C1",Profile_Score__c +RIGHT(MS_Score__c,1),
"C2",Profile_Score__c +RIGHT(MS_Score__c,1),
"C3",Profile_Score__c +RIGHT(MS_Score__c,1),
"C4",Profile_Score__c +RIGHT(MS_Score__c,1),
"D1",Profile_Score__c +RIGHT(MS_Score__c,1),
"D2",Profile_Score__c +RIGHT(MS_Score__c,1),
"D3",Profile_Score__c +RIGHT(MS_Score__c,1),
"D4",Profile_Score__c +RIGHT(MS_Score__c,1),
"E0",Profile_Score__c +RIGHT(MS_Score__c,1),
"E1",Profile_Score__c +RIGHT(MS_Score__c,1),
"E2",Profile_Score__c +RIGHT(MS_Score__c,1),
"E3",Profile_Score__c +RIGHT(MS_Score__c,1),
"E4",Profile_Score__c +RIGHT(MS_Score__c,1),
"U0",Profile_Score__c +RIGHT(MS_Score__c,1),
"U1",Profile_Score__c +RIGHT(MS_Score__c,1),
"U2",Profile_Score__c +RIGHT(MS_Score__c,1),
"U3",Profile_Score__c +RIGHT(MS_Score__c,1),
"U4",Profile_Score__c +RIGHT(MS_Score__c,1),
""
)
Regards,
Ajay