+ Start a Discussion
Raja JammulaRaja Jammula 

Match the values with one value to another value

Hi All 
When the plan project is created from the opportunity, the flow checks for the XYZ fields on the Primary Quote and updates the values on the Plan record that is XYZ fields

I have wriite code like below:

public void populateIndicatorsData(Map<String,String> planWithOpp){
    Map<String,String> planWithOpp = new Map<String,String>();
        List<BigMachines__Quote__c> quotes = [SELECT id,Participant_Distribution_Advice__c,Participant_Investment_Advice__c,
                                                      BigMachines__Opportunity__C 
                                                      FROM BigMachines__Quote__c 
                                                      WHERE BigMachines__Is_Primary__c = true AND BigMachines__Opportunity__c in :planWithOpp.values()]; 
        if(!quotes.isEmpty()){
            Map<String,BigMachines__Quote__c> oppWithQuote = new Map<String,BigMachines__Quote__c>();
            for(BigMachines__Quote__c q : quotes){
                oppWithQuote.put(q.BigMachines__Opportunity__c ,q);
            }
            List<Auto_Bundle__c> PlanListToUpdate = new List<Auto_Bundle__c>();
            for(String planId : planWithOpp.keySet()){
                Auto_Bundle__c plan = new Auto_Bundle__c(id = planId);
                if(oppWithQuote.get(planWithOpp.get(planId)).Participant_Distribution_Advice__c != null && oppWithQuote.get(planWithOpp.get(planId)).Participant_Distribution_Advice__c.toLowercase() != 'null')
                {   
                    plan.Participant_Distribution_Advice__c =  oppWithQuote.get(planWithOpp.get(planId)).Participant_Distribution_Advice__c;
                    
                }
                if(oppWithQuote.get(planWithOpp.get(planId)).Participant_Investment_Advice__c != null && oppWithQuote.get(planWithOpp.get(planId)).Participant_Investment_Advice__c.toLowercase() != 'null')
                {   
                    plan.Participant_Investment_Advice__c = oppWithQuote.get(planWithOpp.get(planId)).Participant_Investment_Advice__c ;
                    
                }
                if(plan.Participant_Distribution_Advice__c != null || oppWithQuote.get(planWithOpp.get(planId)).Participant_Investment_Advice__c != null)
                    PlanListToUpdate.add(plan);
            }
            if(!PlanListToUpdate.isEmpty()){
                update PlanListToUpdate ;
            }
        }
    }

but there is validation rule in the plan object where XYZ (Picklist) field values should match exactly 
But in the quote the picklist values slighlty differs EX: in quote - Find Error (FE), in plan - Find Error
Now, i need to modify my code little bit like: First convert the values in quote to match to the valus in plan and then update the plan

can anyone help me on this on how to write this?
Vivian Charlie 1208Vivian Charlie 1208

Hi Raja,

 

If the format of picklist values is same, that is there are always 2 characters in round brackets eg.

quote - Find Error (FE), Plan - Find Error

quote - Create Error (CE), Plan - Create Error

quote - Delete Error (DE), Plan - Find Error

 

You can use string methods to find first index of ( and then create substring from 0 till the first index of (, Trim this value and it will match the Plan picklist value

 

Thanks

Vivian