You need to sign in to do that
Don't have an account?

How to assign two different values to two different fields based on a conditional statement (In apex)
Error message: "Error: Compile Error: Expression cannot be assigned at line 208 column 36"
Objective: I want to assign two different values to two different fields based on one conditional statement (programmatically)
Code #1:
The code below works as expected but when I tried to add "&&" in Code #2 the code didn't not run.
Code #2:
When adding "&&" to my output part of the conditional statement the code stops working. I get an message: "
Error: Compile Error: Expression cannot be assigned at line 208 column 36"
Objective: I want to assign two different values to two different fields based on one conditional statement (programmatically)
Code #1:
The code below works as expected but when I tried to add "&&" in Code #2 the code didn't not run.
// Determine coverage if (insuranceType == 'BLA') { l.Insurance_type__c = 'Bla bla' l.Qualification_message__c = 'Bla bla Bla bla Bla bla Bla bla'; } else if(NonAcceptedPlans.contains(groupName)) { l.Insurance_type__c = 'Bla bla Bla bla'; } else if(planDescription == '') { l.Insurance_type__c = 'TTT'; } else {l.Insurance_type__c = 'Bla bla Bla bla Bla bla';}
Code #2:
When adding "&&" to my output part of the conditional statement the code stops working. I get an message: "
Error: Compile Error: Expression cannot be assigned at line 208 column 36"
// Determine coverage if (insuranceType == 'BLA') { l.Insurance_type__c = 'Bla bla' l.Qualification_message__c = 'Bla bla Bla bla Bla bla Bla bla'; } else if(NonAcceptedPlans.contains(groupName)) { l.Insurance_type__c = 'Bla bla Bla bla' && l.Qualification_message__c = 'Bla bla Bla bla Bla bla Bla bla'; } else if(planDescription == '') { l.Insurance_type__c = 'TTT' && l.Qualification_message__c = 'Bla bla Bla bla Bla bla Bla bla'; } else {l.Insurance_type__c = 'Bla bla Bla bla Bla bla' && l.Qualification_message__c = 'Bla bla Bla blaBla bla";}
Hope this helps...!!!
Please mark as best answer if the above helps...!!