In the Consumer__c picklist field in the Loan__c custom object, contains the values
- Not reviewed
- Consumer
- Non-consumer
- Insufficient information
- Ambiguous
- Request 1: When a user selects “Non-consumer” in the Consumer__c picklist field in the Loan__c object , in the Opportunity object, the Consumer_Loan__c checkbox = TRUE and the Consumer_Loan_Hidden__c = FALSE. If “Non-consumer” in the Consumer__c picklist field in the Loan__c object is not selected and save , then Consumer_Loan__c checkbox = FALSE
Request 2: When a user selects “Ambiguous”, “'Insufficient information”, or picklist is blank with no value, in the Consumer__c picklist field in Loan__c object , in the Opportunity object, the Consumer_Loan_Hidden__c checkbox = TRUE. If “Ambiguous”, “'Insufficient information”, or picklist is blank with no value, in the Consumer__c picklist field in Loan__c object is not selected or save, then Consumer_Loan_Hidden__c checkbox = FALSEtrigger updateDealWithLoanInfo2 on Loan__c (after insert, after update) { if(Trigger.isAfter && ( Trigger.isInsert || Trigger.isUpdate )) { map<id,id> dealMap = new map<id,id>(); set<id> consumerDeals = new set<id>(); set<id> consumerDeals2 = new set<id>(); set<id> participatedDeals = new set<id>(); list<Loan__c> loans = new List<Loan__c>(); list<Opportunity> deals = new List<Opportunity>(); list<Opportunity> updatedDeals = new List<Opportunity>(); for(Loan__c l : Trigger.new) { if(l.Deal__c <> NULL) { dealMap.put(l.Deal__c, l.Id); } } if(dealMap.size()>0){ loans = [Select Deal__c, Consumer__c, Participated__c from Loan__c where Deal__c in :dealMap.keySet()]; for (Loan__c l2 : loans){ if(l2.Consumer__c != 'Non-consumer'){ consumerDeals.add(l2.Deal__c); } if(l2.Consumer__c != 'Ambiguous' && l2.Consumer__c != 'Insufficient information' && l2.Consumer__c != null ){ consumerDeals2.add(l2.Deal__c); } if(l2.Participated__c == TRUE){ participatedDeals.add(l2.Deal__c); } } deals = [Select Id, Consumer_Loan__c, Consumer_Loan_Hidden__c, Participated_Loan__c from Opportunity where Id in :dealMap.keySet()]; for (Opportunity o : deals){ if(consumerDeals.contains(o.Id)){ o.Consumer_Loan__c = TRUE; }else{ o.Consumer_Loan__c = FALSE; } if(consumerDeals2.contains(o.Id)){ o.Consumer_Loan_Hidden__c = TRUE; }else{ o.Consumer_Loan_Hidden__c = FALSE; } if(participatedDeals.contains(o.Id)){ o.Participated_Loan__c = TRUE; }else{ o.Participated_Loan__c = FALSE; } updatedDeals.add(o); } if(updatedDeals.size()>0){ update updatedDeals; } } }}I appreciate your help on this
3 answers
When I wrote the word "Blank'" , this means there is no value in the Consumer__c picklist field in loans