Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Formula to schedule contact date and time

Avatar

Level 4

We have this formula, it tries to contact Recipients between 8 am and 8 pm,  in this case it is set to 9 am.

I'd like to make it directly, like: send this delivery the next day at 9 am. Or even better that the user the possibility to insert directly the date: 28/09/23 at 9 am. 

Iif( Hour(GetDate())<=8 , AddHours(ToDate(GetDate()),8) , AddHours(AddDays(ToDate(GetDate()),1),9) )

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @ogonzalesdiaz ,

Use the below expression in your delivery's scheduling

Iif(Hour(GetDate())<8,AddHours(DateOnly(GetDate()),9 ) ,Iif(Hour(GetDate())>19,AddDays(AddHours(DateOnly(GetDate()),9 ),1 ) ,GetDate() ) )

 

ParthaSarathy_1-1695729540012.png

 

The above formula works in a way that,

If the delivery gets triggers at before 8 AM, then the delivery's contact will be set to Same day's 9AM.

If the delivery was triggered after 8 PM, then the delivery's contact will be set to Next day's 9AM.

So your Recipient wont get an email before 8 AM and not after 8 PM.

View solution in original post

4 Replies

Avatar

Community Advisor

Hello @ogonzalesdiaz ,

hello is this automated campaign? with continuous delivery? and you want to only deliver messages between 9am 9pm? Or what is that you want? You want trigger campaign from control workflow? 

 

Marcel Szimonisz

MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/

Avatar

Level 4

So this is a manual Campaign, it was a Start activity, not a Scheduler activity. So the idea is that user should be able to start the Campaign at anytime, run the queries and so on, but the delivery should arrive to user only between 8 am and 8 pm.

So instead of: 

Iif( Hour(GetDate())<=8 , AddHours(ToDate(GetDate()),8) , AddHours(AddDays(ToDate(GetDate()),1),9) )

I was looking for formula, like this pseudocode:

Send delivery the next day at X hour.
Or: Send delivery on "dd-mm-yy" at X hour.

Company use Recurring delivery, but I guess the should use  just the Email delivery, right?  Not sure about the difference, will have to investigate.

Avatar

Community Advisor

Hello @ogonzalesdiaz 

 

You can use the bellow code (after tunning it to your use case) to set a different contactDate of a delivery.

The code should be in the ''script'' tab of delivery activity: 

 

//get the current date and time
var contactDate = new Date(); 
//set contactDate to current date and time + 24h
contactDate.setDate(contactDate.getDate()+1);

// tell the current delivery that the routing should be delayed
delivery.scheduling.delayed = true;
// set contactDate of current delivery to the date in the variable contactDate
delivery.scheduling.contactDate = contactDate;

 

 

Br,

Amine

Avatar

Correct answer by
Community Advisor

Hi @ogonzalesdiaz ,

Use the below expression in your delivery's scheduling

Iif(Hour(GetDate())<8,AddHours(DateOnly(GetDate()),9 ) ,Iif(Hour(GetDate())>19,AddDays(AddHours(DateOnly(GetDate()),9 ),1 ) ,GetDate() ) )

 

ParthaSarathy_1-1695729540012.png

 

The above formula works in a way that,

If the delivery gets triggers at before 8 AM, then the delivery's contact will be set to Same day's 9AM.

If the delivery was triggered after 8 PM, then the delivery's contact will be set to Next day's 9AM.

So your Recipient wont get an email before 8 AM and not after 8 PM.