Adding data to a delivery icon from a javascript Icon

Avatar

Avatar
Validate 1
Level 1
karanv22355550
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
karanv22355550
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

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

20-03-2018

Hello! I recently called an API within the JavaScript Icon. I have some data from the API that I would like to use in an email delivery. How would get the data into the delivery Icon. The data will be different per individual we are sending to.

EX:

Individual 1  -> Object.acceptedPrize = 1

Individual 2  -> Object.acceptedPrize = 0

Individual 3  -> Object.acceptedPrize = 0

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 3
kapilsharma0101
Level 3

Likes

14 likes

Total Posts

52 posts

Correct reply

18 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile

Avatar
Validate 1
Level 3
kapilsharma0101
Level 3

Likes

14 likes

Total Posts

52 posts

Correct reply

18 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile
kapilsharma0101
Level 3

21-03-2018

Hi karanv22355550

Yes, you can use the Data from the API in the Email Delivery by using following Steps :

1. Define Some Instance Variables in the JavaScript which will hold the Data from the API.

     Instance Variables Can Be Defined As # instance.vars.xxxxx

2. Use one Enrichment Activity after the JavaScript. -> Add data ->  Data Linked To The Filtering Dimension -> Data of the filtering dimension -> Click On Add -> and add variable there in the below format :

     $(instance/vars/VariableName)

     1447594_pastedImage_1.png

3. Now select one Delivery Activity -> Click On Source In The Delivery -> Click On Last Icon On The Tab -> Target Extension -> And Here You Can See Your Variable Defined Previously -> Just Click on that and now you can simply use it in the Delivery Activity.

1447604_pastedImage_2.png

Answers (3)

Answers (3)

Avatar

Avatar
Springboard
MVP
MarcelSzimonisz
MVP

Likes

104 likes

Total Posts

227 posts

Correct reply

56 solutions
Top badges earned
Springboard
Establish
Contributor
Give Back 25
Give Back 10
View profile

Avatar
Springboard
MVP
MarcelSzimonisz
MVP

Likes

104 likes

Total Posts

227 posts

Correct reply

56 solutions
Top badges earned
Springboard
Establish
Contributor
Give Back 25
Give Back 10
View profile
MarcelSzimonisz
MVP

21-03-2018

Hello karanv22355550​,

Adobe instance vars and vars can hold string values only.

If you want to store objects in them you can  use built in JSON.stringify()

var myObject = {["obj1":"value1"]};

var myArray = [1,2,3];

//convert object to string

instance.vars.myObject = JSON.stringify(myObject);

instance.vars.myArray = JSON.stringify(mymArray);

/at any other place in the same worfklow

//convert string to object

var myObject = JSON.parse(instance.vars.myObject);

var myArray = JSON.parse(instance.vars.myArray);

Best Regards,

Marcel

Avatar

Avatar
Validate 1
Level 1
karanv22355550
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
karanv22355550
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

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

21-03-2018

Can you also store arrays of objects as instance variables?

Thanks!

Avatar

Avatar
Validate 1
Level 1
karanv22355550
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
karanv22355550
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

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

21-03-2018

Two Quick Questions,

1) Can I store Javascript Objects as instance.vars?

instance.vars.obj

So I could call them like this,  $(instance/vars/obj.name)

and it would return the persons name.

but if I do $(instance/vars/obj.number)

it would return their number.

2)Each API call has specific data to that individual. Same variables but different data. How can I associate that with the individual in adobe.

Example:

I call the api on 3 individuals

The object returns that the first individuals acceptedPrize is 1

Then the second individuals accepted price is 0

The thirds is 0.

Individual 1  -> Object.acceptedPrize = 1

Individual 2  -> Object.acceptedPrize = 0

Individual 3  -> Object.acceptedPrize = 0