after changing the name of a Script token it doesn't work anymore

LydiaKarakuz
Level 2

after changing the name of a Script token it doesn't work anymore

Hello all, 

 

at this weekend I created that token for a tracking link. After creating it everything worked fine, but after changing the name of the token it doesn't work anymore.

 

The script of the script token was is this one:

 

 

#set($carFirstLACategory = "887")
#set($consolidationFirstLACategory = "8992946")
#set($freelanceFirstLACategory = "40895887")
#set($livingFirstLACategory = "886")
#set($freeusageFirstLACategory = "888")
#if($lead.cma_latestLaCategory == "CAR")
#set($lead.cma_latestLaCategory = $carFirstLACategory)
#elseif($lead.cma_latestLaCategory == "HOME")
#set($lead.cma_latestLaCategory = $livingFirstLACategory)
#elseif($lead.cma_latestLaCategory == "TRADE")
#set($lead.cma_latestLaCategory = $freelanceFirstLACategory)
#elseif($lead.cma_latestLaCategory == "CONSOLIDATION")
#set($lead.cma_latestLaCategory = $consolidationFirstLACategory)
#else
#set($lead.cma_latestLaCategory = $freeusageFirstLACategory)
#end
${lead.cma_latestLaCategory}

 

 

 

With this script it showed me, depending on the category a customer has, the number I needed. 

 

Everything worked fine, till today morning when I changed to token name from "Tracking_link" to "category", everything was fine and the script worked. Now it always shows me the number "888" even though it should show me "887". 

 

Why does that happen?

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: after changing the name of a Script token it doesn't work anymore

Changing the name of the token doesn't change how it works. But make sure the fields didn't accidentally become unchecked in the tree. This can happen sometimes when editing tokens in the UI.

LydiaKarakuz
Level 2

Re: after changing the name of a Script token it doesn't work anymore

I know that it should not change how it works and I checked if the necessary bos is checked.  It is checked. 

 

I don't know why, but sometimes the script works and sometimes not. I checked yesterday multiple times and it didn't worked. Today in the morning it worked, and now it doesn't work anymore. 

 

I check the mail with preview from Customer perspective, the mail recognizes the regementation but the token does not.

LydiaKarakuz
Level 2

Re: after changing the name of a Script token it doesn't work anymore

@SanfordWhiteman 

While testing I observated following issue:

 

When I create a new template and test an CTA with the token it works. After I finished creating the mail the CTA does not work anymore with that token. 

 

Why does that happen? 
I need to know ASAP what this issue is about and what is the progess on your site to fix it. 

 

Best regards

Lydia

SanfordWhiteman
Level 10 - Community Moderator

Re: after changing the name of a Script token it doesn't work anymore

The behavior you describe is quite bizarre. Tokens don't just get deactivated like that.

 

One thing you're doing that you shouldn't be is setting new property values and/or property names on $lead. 

 

Technically the $lead HashMap appears editable, but it should be treated as if it's read-only. 

 

If you want to set properties on an object instead of setting top-level variables, create a new object:

#set( $workingLead = {} )

 

Then you can #set properties on that:

#set( $workingLead.someCustomProperty = "someValue" )

 

LydiaKarakuz
Level 2

Re: after changing the name of a Script token it doesn't work anymore

@SanfordWhiteman 

I know this sounds bizzare, but this is what is happening right know. I can show it to you if you don't believe. 

 

As I have actually no knowledge of Java Script you have to be more clear about the issue you are talking about.

 

 

I created new values with $carFirstLACategory = "887"

 

The value $lead.cma_latestLaCategory is a company value that is already implemented at our company Map.

 

So please tell me clear what I would have to change, so that the scipt works permanently

 

#set($carFirstLACategory = "887")
#set($consolidationFirstLACategory = "8992946")
#set($freelanceFirstLACategory = "40895887")
#set($livingFirstLACategory = "886")
#set($freeusageFirstLACategory = "888")
#if($lead.cma_latestLaCategory == "CAR")
#set($lead.cma_latestLaCategory = $carFirstLACategory)
#elseif($lead.cma_latestLaCategory == "HOME")
#set($lead.cma_latestLaCategory = $livingFirstLACategory)
#elseif($lead.cma_latestLaCategory == "TRADE")
#set($lead.cma_latestLaCategory = $freelanceFirstLACategory)
#elseif($lead.cma_latestLaCategory == "CONSOLIDATION")
#set($lead.cma_latestLaCategory = $consolidationFirstLACategory)
#else
#set($lead.cma_latestLaCategory = $freeusageFirstLACategory)
#end
${lead.cma_latestLaCategory}