Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

Enrichment Help

Avatar

Level 3

Hey everyone,

Hope someone can help.

1429859_pastedImage_10.png

I'm trying to enrich an email with some custom date fields which will act as the validity dates for the customer - I've added these in an enrichment.

Here's my workflow - you might be able to workout that it's a birthday trigger email.

1429847_pastedImage_0.png

You'll see inside my split is nothing insane:

1429848_pastedImage_2.png

And here's my Enrichment:

1429849_pastedImage_3.png

When I hit "Edit Additional data.."

1429850_pastedImage_4.png

And going back to the Reconciliation table:

1429851_pastedImage_5.png

Note: I wasn't sure if this was necessary or not but hey ho!

Anyway, when I add these fields into a recurring delivery:

1429852_pastedImage_6.png

And when I preview... I get this:

1429856_pastedImage_7.png

...and in a continuous delivery I get this:

1429858_pastedImage_9.png

Any help?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Kevin,

You should use a formatDate function to format your dates in deliveries.

in your case you have two options:

Options 1: efficient solution( if a developer is involved while preparing deliveries.)

add this script in the top of your delivery

<%

var currentDate = new Date();

var startDate = new Date();

var endDate = new Date();

// add a day

startDate.setDate(currentDate.getDate() + 7);

endDate.setDate(currentDate.getDate() +14);

%>

Use below syntax for adding these to your content wherever applicable

<%= formatDate(startDate, "%2D/%2M/%4Y") %>

<%= formatDate(endDate, "%2D/%2M/%4Y") %>

Options 2:

remove all extra formatting apart from adding days to current date and do not use toDate or any other function in your enrichment i.e use only AddDays(GetDate(),7 ) and then Use below option to include your dates.

<%= formatDate(targetData.startDate, "%2D/%2M/%4Y") %>

<%= formatDate(targetData.endDate, "%2D/%2M/%4Y") %>

Regards,

Amit

View solution in original post

16 Replies

Avatar

Employee

Hi,

I have also faced this problem where the target variable from Enrichment is not available/usable, sometimes (not sure of the reason though). I use a workaround for this and below is the process.

1429913_pastedImage_0.png

  1. Please see that the alias has been modified inside Enrichment output columns and the new field is called @newFirstName.
  2. Also referring to schema of enrichment the temporary table can be referenced using schema temp:enrich.
  3. Inside JS code activity, perform a queryDef call on this temp schema and then read from the relevant column.

  4.  Pass the instance variable in the delivery

Avatar

Level 10

Hi Kjac,

Usually, such evaluation error is whenever you try to preview your delivery outside the workflow (that is possible only for control addresses with targetData specifically defined). Please use your workflow to open the delivery and display the preview.
In such way, do you face with the same issue?

Regards
J-Serge

Avatar

Level 3

Hi J-Serge,

Yes, my screenshots were from the delivery inside my workflow.

Any other suggestions?

- K

Avatar

Level 3

Thanks for this Rama,

It's a little hard to see your screenshot in its entirety.

Would you be able to upload a larger screenshot?

Thanks

Kevin

Avatar

Level 10

Hi Kjac,

Why do you put a @ for your alias ? please may you try by writing your alias directly startDate ?

Regards
J-Serge

Avatar

Employee

Here is the code for you from the screenshot.

var query = xtk.queryDef.create( <queryDef schema="temp:enrich" operation="select"> <select> <node expr="@newFirstName"/> </select> </queryDef>); var resultSet = query.ExecuteQuery(); for each (var row in resultSet) { logInfo("From temp schema : " + row.@newFirstName); instance.vars.AKTEST = row.@newFirstName; logInfo("From instance variable : " + instance.vars.AKTEST); }

Avatar

Employee

Hi Kjac,

Once you create the instance variable, you may not able to use the instance variable directly in the delivery (you can use it in the alert activity within the WF, though). Instead, create a variable (step 4) in the delivery properties (shown below) and use the script delivery.variables._var[0].stringValue = instance.vars.AKTEST in the delivery script (step 3).

Steps:

1. create a workflow (not a campaign with a workflow in it) with the type of delivery, shown below (which can be available only in a independent workflow and not in a targeting workflow of a campaign).

2. Follow the steps in screen grab till JS and connect the JS to a delivery (shown below).

1431819_pastedImage_1.png

3. Open the delivery and you see the screen below. Map the delivery template (RJS TEST Email Delivery below) you created under Delivery templates folder in the Delivery Tab and paste the script delivery.variables._var[0].stringValue = instance.vars.AKTEST in the script tab.

1431820_pastedImage_2.png

1431829_pastedImage_8.png

4. Save the WF and go to the delivery template you created under Delivery templates (RJS TEST Email Delivery in this case) and do the following.

1431827_pastedImage_4.png

1431828_pastedImage_5.png

This worked for me and please let me know, if you have any questions. However, using JS in the workflows will hamper performance of the instance. So i have tried to change and maintain the same targeting dimension at WF and delivery level for the target data to work. But, this did not work, too.

Thanks,

Rajesh

Avatar

Level 2

Hi,

You will be able to see start date and end date correctly when you will send a delivery. Try to send some test data and you will see dates are displayed correctly. You get error because while previewing delivery in the workflow, it picks up data which is present in the schema columns. It does not picks up data stored in the workflow.

However, when you send a delivery, it does compute <%=targetdata.startdate%> correctly during analysis phase.

Thanks,

Jyoti

Avatar

Level 3

Thanks Rajesh, I'll see if I can replicate.

Avatar

Level 3

Hi Jyoti,

Interestingly, I sent it to myself and the dates did compute as you suggested, though not as I intended.

1433506_pastedImage_0.png

Any ideas how to change the format to something else?

- Kevin

Avatar

Level 3

Note: I was expecting dates like this:

1433525_pastedImage_0.png

Avatar

Level 2

Hi Kevin,

When you are saving dates in the variable,  save them as :

DateOnly(ToDate(xxx))

You will get only date parameter,  no timestamp.

Thanks,

Jyoti

Avatar

Level 3

Hi Jyoti,

Thanks for reply so quickly.

I added DateOnly() to the enrichment..

1433534_pastedImage_1.png

but all it did is set the time as 00:00:00.

1433512_pastedImage_0.png

. I was thinking of using formatdate() in the delivery but it will only work with system date... any other suggestions?

Thanks

Kevin

Avatar

Level 2

Hi Kevin,

Try with this:

Left( ToDate(xxx),12)

This will truncate the time part and stores only initial 12 characters of the string.

Thanks,

Jyoti

Avatar

Correct answer by
Level 10

Hi Kevin,

You should use a formatDate function to format your dates in deliveries.

in your case you have two options:

Options 1: efficient solution( if a developer is involved while preparing deliveries.)

add this script in the top of your delivery

<%

var currentDate = new Date();

var startDate = new Date();

var endDate = new Date();

// add a day

startDate.setDate(currentDate.getDate() + 7);

endDate.setDate(currentDate.getDate() +14);

%>

Use below syntax for adding these to your content wherever applicable

<%= formatDate(startDate, "%2D/%2M/%4Y") %>

<%= formatDate(endDate, "%2D/%2M/%4Y") %>

Options 2:

remove all extra formatting apart from adding days to current date and do not use toDate or any other function in your enrichment i.e use only AddDays(GetDate(),7 ) and then Use below option to include your dates.

<%= formatDate(targetData.startDate, "%2D/%2M/%4Y") %>

<%= formatDate(targetData.endDate, "%2D/%2M/%4Y") %>

Regards,

Amit

Avatar

Level 3

Thanks Amit,

Option 2 worked for me perfectly.

Thanks

Kevin