Output from velocity has 4 blank spaces in front of string | Community
Skip to main content
SaurabhGoyal_GN
New Participant
March 20, 2024
Solved

Output from velocity has 4 blank spaces in front of string

  • March 20, 2024
  • 2 replies
  • 2893 views

Hi there,

I am currently encountering a problem while trying to fetch a field value from a custom object to use it in an email.

 

Specifically, I am retrieving a string from the custom object to use as the value of a query parameter in the URL within the email.

 

Please refer to the VTL code below and the attached screenshot of the email.

 

ISSUE can be noticed at the bottom left of the screenshot.

 

I have already verified the value in the custom object and confirmed that there are no spaces included.



NOTE - I checked the value in CO, if that is having the spaces included but answer is NO. There is no spaces in the value on CO. 

Looking forward for some insights here. 

#set($listing = $sorter.sort(${listings_cList}, ["listing_registration_start_date_time:asc"])) #if($list.listing_status_completed.equals('0')) #set($listingtoken = $list.listing_token) $listingtoken #end

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

You have 4 spaces in front of the output! It’s right there in your code. So that’s the clear reason. VTL is always space-preserving.

 

As Darshil says, the approach you’re using with one part of an <a> outside of the token isn’t supported anyway. Move everything inside the token.

2 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
March 20, 2024

You have 4 spaces in front of the output! It’s right there in your code. So that’s the clear reason. VTL is always space-preserving.

 

As Darshil says, the approach you’re using with one part of an <a> outside of the token isn’t supported anyway. Move everything inside the token.

Darshil_Shah1
Community Manager
March 20, 2024

Instead of adding the UTM to the URL, can you display it raw(just the UTM value) to see whether it has spaces?  The VTL code you have mentioned in the question doesn't have the part where you’re adding the UTM from the CO record at the end of the URL.

SaurabhGoyal_GN
New Participant
March 20, 2024

@darshil_shah1 - 

Here are the different screenshot, these may will provide the clearity on the problem.

Scrennshot 1 shows edit draft mode of the email - Behind the word "hyperlink" I have applied the URL, same as above the same.

 

 

Screenshot 2 shows the preview of the email, with URL in the left bottom.

 

Screenshot 3 shows the inspect element of the module.

Darshil_Shah1
Community Manager
March 20, 2024

Why don't you output the entire anchor tag using the velocity? You would lose on the tracking data if you don't fully-form and output the entire anchor tag (<a> through </a>) from the velocity.