Velocity Script - Default Value Issue | Community
Skip to main content
Cristina_Leonet
Level 2
Jun 19, 2019 4:26 PM UTC
Solved

Velocity Script - Default Value Issue

Hello All,

I'm trying to set a default value to my velocity script but seems I'm doing mistakes coding the script but I don't know where I'm doing wrong.

The script is cutting the abbreviation from the sales person name, if empty we want to display another value. The code returns an error:

#set ($accountOwner = $lead.Account_Owner__c)#if ($accountOwner == "")The Company Team #else  #set ($accountOwnerSimple = $accountOwner.replaceAll("\s*\(.*\)\s*$", ""))Here's the $accountOwnerSimple

I'm not a developer so I'm sorry if the coding seems stupid to you! I'm learning!

Thanks in advance,

Cristina

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Jun 19, 2019 4:44 PM UTC

Your script has a syntax error as it's missing an #end.

Also, please always highlight the code as Java using the Advanced Editor's syntax highlighter, as I've done here:

#set ($accountOwner = $lead.Account_Owner__c)
#if ($accountOwner == "")
The Company Team
#else
#set ($accountOwnerSimple = $accountOwner.replaceAll("\s*\(.*\)\s*$", "") )
Here's the $accountOwnerSimple
#end‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The script is cutting the abbreviation from the sales person name

I don't know what you mean by this, so I can't tell you if the regex is correct.

3 replies

Cristina_Leonet
Level 2
Jun 20, 2019 9:37 AM UTC

@Sanford Whiteman‌ Thanks a lot!   

Translate
SanfordWhiteman
Level 10
Jun 20, 2019 3:42 PM UTC

Sure, could you mark my answer as Correct pls?

Translate
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Jun 19, 2019 4:44 PM UTC

Your script has a syntax error as it's missing an #end.

Also, please always highlight the code as Java using the Advanced Editor's syntax highlighter, as I've done here:

#set ($accountOwner = $lead.Account_Owner__c)
#if ($accountOwner == "")
The Company Team
#else
#set ($accountOwnerSimple = $accountOwner.replaceAll("\s*\(.*\)\s*$", "") )
Here's the $accountOwnerSimple
#end‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The script is cutting the abbreviation from the sales person name

I don't know what you mean by this, so I can't tell you if the regex is correct.

Translate