Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have condition where doing insert in Salesforce.
If field1= 'CHQ' then FinalDate = date1
else if field1 = 'CB' then FinalDate = Date2
In Salesforce, field is null
Can SomeOne Help me.
Hello aichas,
your code in the attached GIF is almost correct. Please do not use "==" for comparing strings, use the .equals() method.
((row4.TypeCoupon.equals("CHQ") ? row4.DateCheque : row4.DateDignature))
For your example given in the text, you can nest such ternary statements. The formula for "FinalDate" could be
field1.equals("CHQ") ? date1 : field1.equals("CB") ? Date2 : date3
"date3" is the value for "FinalDate" if field1 is not equal to "CHQ" or "CB".
Best regards,
Thomas
Hello aichas,
your code in the attached GIF is almost correct. Please do not use "==" for comparing strings, use the .equals() method.
((row4.TypeCoupon.equals("CHQ") ? row4.DateCheque : row4.DateDignature))
For your example given in the text, you can nest such ternary statements. The formula for "FinalDate" could be
field1.equals("CHQ") ? date1 : field1.equals("CB") ? Date2 : date3
"date3" is the value for "FinalDate" if field1 is not equal to "CHQ" or "CB".
Best regards,
Thomas
Hi,
just a small tip. Instead of using this:
field1.equals("CHQ")
use that:
"CHQ".equals(field1)
And you won't have NullPointerException anymore when field1 is null
Regards