I am running a journey where I added an email template. In the email template, there is some link that is DST time-specific (11 AM - 01 PM). If someone clicks on that link it will open in between specific times otherwise gives an error. How to achieve by AMPscript?
Mateusz DÄ…browski
You cannot achieve it with AMPscript within the email itself - once an email is sent, it is sent, and the AMPscript was already executed during send time.
What you could do is create a Code Resource in Web Studio that would have AMPscript checking the time: https://salesforce.stackexchange.com/a/354511, and based on that check and your hardcoded boundaries, it would redirect either to your final link or to an error page. In the email, you would link to that Code Resource as an intermediary page.
Configure the following AMPscript on the Cloudpage.
%%[IF DateDiff('00:00',SystemDateToLocalDate(Now()),'h') >= 11
AND DateDiff('00:00',SystemDateToLocalDate(Now()),'h') < 13
OR DateDiff('00:00',SystemDateToLocalDate(Now()),'h') >= 35
AND DateDiff('00:00',SystemDateToLocalDate(Now()),'h') < 37 THEN]%%
<!--- From AM11:00 to PM13:00 --->
%%=Redirect('https://www.salesforce.com/')=%%
%%[ELSE]%%
<!--- From PM13:00 to AM11:00 --->
Oops! Something went wrong.
%%[ENDIF]%%
Comments
Post a Comment