Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

If logic not working

Avatar

Avatar
Validate 1
Level 1
bryceh57660644
Level 1

Like

1 like

Total Posts

16 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
bryceh57660644
Level 1

Like

1 like

Total Posts

16 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
bryceh57660644
Level 1

01-06-2021

Situation: I have created a 6 page micorsite for lead generation. The site has the ability to take in lead source variables that we pass through and I was looking to add in a backup as we have seen some gaps recently with this variable.  To fix the issue, I added in some JS to capture the tracking tag from a link and pass it through all the pages until they hit submit on the form. To do this I had to add in an if statement to only fill the variable if it is empty/null/undefined, but my logic isnt working and its repopulating on every page.  From what I can tell the IF itself isnt wrong, but when I search in the consol for the variable it doesnt appear, although it does in the AC debug mode. If the IF thinks the variableis empty, this would make sense why it is updating it constantly, but I cant figure out why its reading the variable that way. Any idea what I am doing wrong?

 

Site: https://www.sunlife.ca/ma//webApp/pma-index?WT.mc_id=en-us:direct:promo_email:provider_email:How-it-...

JS (fires onload):

function updateTrackingTag() {
var TrackingTag = document.controller.getValue('/ctx/vars/trackingtag');
if (TrackingTag !== "" || TrackingTag !== undefined || TrackingTag !== null) {
document.controller.setValue('/ctx/vars/trackingtag', TrackingTag);}
else {
document.controller.setValue('/ctx/vars/trackingtag', location.search);}
}

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

115 likes

Total Posts

327 posts

Correct Reply

100 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

115 likes

Total Posts

327 posts

Correct Reply

100 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile
_Manoj_Kumar
MVP

01-06-2021

Hello @bryceh57660644 

 

follow these steps

  • Remove  // <![CDATA[  -> Available on the top of function 
  • Add a default value to trackingtag variable in web app properties. Lets says its 0
  • Then change if condition to  if(TrackingTag!='0')

Thanks,

Manoj

 

 

 

Avatar

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

154 likes

Total Posts

910 posts

Correct Reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

154 likes

Total Posts

910 posts

Correct Reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile
Sukrity_Wadhwa
Employee

23-06-2021

Hi @bryceh57660644,

Were you able to resolve this query with the given solution or do you still need more help here? Do let us know.

Thanks!

Avatar

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

115 likes

Total Posts

327 posts

Correct Reply

100 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

115 likes

Total Posts

327 posts

Correct Reply

100 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile
_Manoj_Kumar
MVP

01-06-2021

@bryceh57660644 

 

Can you try changing your code to this one?.

function updateTrackingTag() {
var TrackingTag = document.controller.getValue('/ctx/vars/trackingtag');
if (TrackingTag != "" || TrackingTag != undefined || TrackingTag != null) {
document.controller.setValue('/ctx/vars/trackingtag', TrackingTag);}
else {
document.controller.setValue('/ctx/vars/trackingtag', location.search);}
}

 

I am assuming it is not working because of data type issue.

 

Thanks,

Manoj