Re: IF/THEN logic in velocity script token

jordannams
Level 1

IF/THEN logic in velocity script token

we want to link to the self scheduler link if it’s populated and link to a default if it’s not. We also want to add a UTM query string to the end of the unique self scheduler link. Here is the logic I currently have: 

 

jordannams_0-1713985037819.png

 

 

the else is working but the if is not, any insight?

8 REPLIES 8
Jo_Pitts1
Level 10 - Community Advisor

Re: IF/THEN logic in velocity script token

@jordannams ,

firstly, here's how to post code into Marketo nation: https://nation.marketo.com/t5/product-blogs/posting-code-in-discussions/ba-p/341001/highlight/true

 

Secondly, what do you mean by 'the if is not'?  Do you mean the output being generated doesn't work?  Do you mean people never get into the if side of the condition when you believe that should?

 

As a random suggestion, have you made sure the selfSchedulerLink field is checked in the tree on the RHS of the script editor?

 

Cheers

Jo

 

Regards

Jo

jordannams
Level 1

Re: IF/THEN logic in velocity script token

Thank you so much for that! I am very new to Marketo (used SFMC previously) so this is very much a learning process and I appreciate all of the feedback.

 

So, by "the if is not" I mean that every time I test this token, it returns the default link instead of the self scheduler link even when it is not empty.

 

jordannams_0-1714051008319.png

 

I do have the Self Scheduler clicked in the right side - is this what everyone is referring to here? 

 

Thank you again and I apologize for the lack of knowledge!

SanfordWhiteman
Level 10 - Community Moderator

Re: IF/THEN logic in velocity script token

@jordannams please remember to use the Syntax Highlighter when inserting code. Although here a screenshot is also useful, it’s not possible to find code errors from a screenshot.

SaurabhGoyal_GN
Level 4

Re: IF/THEN logic in velocity script token

hi @jordannams - Seems like you haven't checked the property selfSchedulerLink is right pane of editor. Please check and confirm. 

jordannams
Level 1

Re: IF/THEN logic in velocity script token

Thank you for your response - please see my update in the post above yours 🙂 Any help is greatly appreciated!

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: IF/THEN logic in velocity script token

@jordannams, could you share the output you're seeing vs. the expected output using the email preview mode? Go to the Email Preview mode >> Select a test record >> Share the actual and desired outputs. Of course, as shared by users above, you'd need to check the lead field you're using in the velocity script; otherwise, the velocity can't reference its data.

Katja_Keesom
Level 10 - Community Advisor + Adobe Champion

Re: IF/THEN logic in velocity script token

I agree with the guys that inserting your code properly would have been easier, but even with the screenshot my first guess would be that you need to remove the quotation marks around the two tokens making up your "if" url. When your type actual text you need to add quotation marks, but that does not apply to tokens.

SanfordWhiteman
Level 10 - Community Moderator

Re: IF/THEN logic in velocity script token

The href attribute must be quoted. You can’t have equals signs in an unquoted HTML attribute.

 

(But here we are discussing something that really should be considered unreadable, and just as important unrunnable.)