Expand my Community achievements bar.

How to populate a variable from JavaScript to a column in Data Extraction Activity?

Avatar

Level 7

Hello Friends,

I have a requirement, where we have to fetch some recipient data and export the same data in a file. Let me give background in detail:

1. Initially we will be fetching some Recipient Data (say 10 records) and retrieving their First Name, Mobile and Email (just example) from Query.

2. Next we will be inserting a record in schema (Transient) created. This schema consists of below fields:

     a. Campaign Identifier (A string value passed in JavaScript as input)

     b. Record Count (A Integer which will store the number of recipients fetched from query (Count)

     c. Primary Key (Auto - generated, whenever a record is inserted)

3. So assume Campaign Identifier is XYZ, Record Count is 10, i will be inserting this two fields in above schema and it somehow looks like below

PRIMARY KEY|Campaign Identifier|Record Count

154878931|XYZ|10

4. Now i need to export the First Name, Mobile and Email of the Recipients to a file using Data Extraction along with PRIMARY KEY mentioned above.

5. So once file is exported and generated over SFTP, it should somehow look like below:

PRIMARY KEY|First Name|Mobile|Email

154878931|ABC|456|gmail.com

154878931|XYZ|456|gmail.com

154878931|PQR|456|gmail.com

154878931|DEF|456|gmail.com

154878931|GHI|456|gmail.com

154878931|KJL|456|gmail.com

154878931|MNO|456|gmail.com

154878931|STU|456|gmail.com

154878931|WXY|456|gmail.com

154878931|ABC|456|gmail.com

6. So I want that Primary Key to be populated for each and every record as shown above.

Can anyone please help me over here. Quick help is appreciated !

Regards,

Sri Bhargav

2 Replies

Avatar

Employee

Hi Sri Bhargav,

Please use an Enrichment activity before data extraction activity to add a new "Primary Key" column in the temporary schema.

Here, I have stored the primary key of the transient table in an event variable "vars.key". In the Enrichment activity, go to "Edit Additional Data" and add a new output column to store the key.

1574696_pastedImage_0.png

After this, you will be able to see "Key" in the Data Extraction activity as available columns and add it to the export file.

1574697_pastedImage_1.png

Thanks,

Nainy Jain

Avatar

Level 7

Thank you very much nainyjain. It worked fine