Hello all, I fell like I am getting crazy. I want to create a solution in wich if there is a phone number of a credit advisor than display it, if it is empty display the default number. The default number is displayed without any problem. But instead of the credit Advisor Phone number it displays "bestOfferBankAmountOfRate".
I tested if the {{lead.creaditadvisorphne}} works and it does. So I have no clue where I made a mistake. This is the script I used:
#set( $a = ${lead.creditAdvisorPhone})
#if("$a" == "")
#set($b = "0800 XXX XX XX")
#end
${b}
Thank you in advance
Solved! Go to Solution.
You must use descriptive variable names: $a and $b are no way to code! You will encounter errors that are impossible to debug if you do this in Velocity, since there is only one global variable scope.
It sounds like you want this:
#set( $defaultAdvisorPhone = "0800 000 98 00" )
#if( !$lead.creditAdvisorPhone.isEmpty() )
#set( $creditAdvisorPhone = $lead.creditAdvisorPhone )
#else
#set( $creditAdvisorPhone = $defaultAdvisorPhone )
#end
${creditAdvisorPhone}
Not sure what you were expecting to happen before, but I suspect you reused $b by accident.
Also note the proper use (or non-use) of curly braces and quotes in the code.
Can you highlight your code using the syntax highlighter, please? Then we'll continue.
#set( $a = ${lead.creditAdvisorPhone})
#if("$a" == "")
#set($b = "0800 000 XX XX")
#end
${b}
Hello @SanfordWhiteman
thank you in advance, as wished I highlighted the code.
You must use descriptive variable names: $a and $b are no way to code! You will encounter errors that are impossible to debug if you do this in Velocity, since there is only one global variable scope.
It sounds like you want this:
#set( $defaultAdvisorPhone = "0800 000 98 00" )
#if( !$lead.creditAdvisorPhone.isEmpty() )
#set( $creditAdvisorPhone = $lead.creditAdvisorPhone )
#else
#set( $creditAdvisorPhone = $defaultAdvisorPhone )
#end
${creditAdvisorPhone}
Not sure what you were expecting to happen before, but I suspect you reused $b by accident.
Also note the proper use (or non-use) of curly braces and quotes in the code.
Thank you sooo much! It worked great!