Hello-
I am trying to create a velocity script. For instance, I want anyone who has a 19 in the year segmentation to set date to 1990.
If Year contains 20 set Date to 2000
If Year contains 19 set Date to 1990
If Year contains 18 set Date to 1980
How do I write the script to achieve the above?
You're missing #end at the end of the #if construct. Additionally, you don't need {} around the variable/field unless you are displaying its value
#if ($T._Year__c.contains("20"))
#set($date = "2000")
#elseif ($T._Year__c.contains("19"))
#set($date = "1990")
#elseif ($T._Year__c.contains("18"))
#set($date = "1980")
#end
${date}
Edit- As Sandy notes, I have a similar question too - Are you sure about using the contains() function? FYR contains() checks for the presence of the substring in a string, as opposed to other functions like startsWith() that check whether the string starts with the specified sub-string.
Darshil, I think there’s more going on than just the syntax.
Please return to your thread and check responses, @mkmarketo1.
Great points, Sandy! Re point #3, I too noticed the strange object name (T). I thought the OP just replaced the actual object name and replaced it with "T", but always a great idea to confirm with the OP to be 100% clear.
I thought the OP just replaced the actual object name and replaced it with "T", but always a great idea to confirm with the OP to be 100% clear.
Hope not because that’s even more confusing.