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

storing an array of strings in a profile attribute

Avatar

Avatar
Validate 1
Level 1
kevin_faurholt
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
kevin_faurholt
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
kevin_faurholt
Level 1

15-10-2015

Hi,

I have the following profile script:

user.arrayTest

if (mbox.name == "kevins_mbox") {
  user.setLocal("arrayTest", ["hello", "world"]);
  return user.getLocal("arrayTest");
}

However, when trying to use the array in a JS offer via: ${user.arrayTest}

The final output looks like this: [hello, world] - i.e. the quotes are missing and a JavaScript error is thrown.

According to this document: http://microsite.omniture.com/t2/help/en_US/tnt/pdf/js_expression_cheat_sheet.pdf

"Script Profile Parameters are found under the mboxes/profiles tab. You 
can write Javascript programs that return any Javascript type (String, 
integer, array, etc)"

Can someone tell me what I am doing wrong here?

Many thanks,

Kevin

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Employee
AllDayDev
Employee

Likes

33 likes

Total Posts

138 posts

Correct Reply

73 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile

Avatar
Boost 5
Employee
AllDayDev
Employee

Likes

33 likes

Total Posts

138 posts

Correct Reply

73 solutions
Top badges earned
Boost 5
Boost 3
Boost 25
Boost 10
Boost 1
View profile
AllDayDev
Employee

15-10-2015

With just the snippet above, quotation marks should not be getting removed.

However, they would not be printed out if you were trying to display/use one of the elements of the array. i.e. you would need to something like this get the quotation marks printed out:

['"hello"', '"world"']

It would be helpful to have some more context.

What is the JavaScript error you are getting?

Can you be more specific about what you are doing with ${user.arrayTest}?

Is it possible to share the page on which you are trying to implement this custom code? a link to the page, the page code, etc.

 

- Carey

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 1
kevin_faurholt
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
kevin_faurholt
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
kevin_faurholt
Level 1

15-10-2015

Hi Avik,

Thanks for your reply. I am passing the array with quoted elements. Point is, that is not what is returned from the TnT engine (missing the quotes)

Avatar

Avatar
Boost 1
Level 3
Avik_Banerjee
Level 3

Likes

2 likes

Total Posts

33 posts

Correct Reply

13 solutions
Top badges earned
Boost 1
Applaud 5
Applaud 50
Applaud 25
Applaud 100
View profile

Avatar
Boost 1
Level 3
Avik_Banerjee
Level 3

Likes

2 likes

Total Posts

33 posts

Correct Reply

13 solutions
Top badges earned
Boost 1
Applaud 5
Applaud 50
Applaud 25
Applaud 100
View profile
Avik_Banerjee
Level 3

15-10-2015

Hi Kevin,


Maybe if you fixed the quotes the output would look right.

 

Thanks,

Avik