0

I received an automation message from Marketing Cloud about this problem in my ampscript and due this the Triggered Send - Cancellation.

The message: Error Message:An error occurred when attempting to evaluate a DateAdd function call. See inner exception for details. ExactTarget.OMM.InvalidFunctionParameterException: Invalid value specified for function parameter. What could be wrong?

%%[

var @phrase, @phrase1, @phrase2, @brasilDateTime, @date, @hour 
set @phrase1= "As soon as possible will be solved."
set @brasilDateTime = DateAdd([Task:What:Case:EstimatedStandardizationTime__c],'-3','H')
set @date = Format(@brasilDateTime,"dd/MM")
set @hour = Format(@brasilDateTime,"HH:mm")
set @phrase2= concat("The forecast is that until", " ", @hour, " ","of day", " ", @date, " ", "will be solved.")

if not empty(@brasilDateTime) then
    set @phrase= @phrase2
else
    @phrase= @phrase1

endif

]%%

%%=v(@phrase)=%%
2
  • 'Task:What:Case:EstimatedStandardizationTime', Is this value null for any of your record? Commented Oct 23, 2020 at 11:50
  • yes @SwatiMishra. The value could be null, i want to I want to direct if it is null send a different phrase.
    – João
    Commented Oct 23, 2020 at 11:52

1 Answer 1

1

If 'Task:What:Case:EstimatedStandardizationTime' can be a null value then you need to add the below line in your code. The reason for error is that Dateadd cannot add a null value.

IF(NOT EMPTY([Task:What:Case:EstimatedStandardizationTime__c])) THEN

Your final code could be something like this :

%%[

var @phrase, @phrase1, @phrase2, @brasilDateTime, @date, @hour 
set @phrase1= "As soon as possible will be solved."
IF(NOT EMPTY([Task:What:Case:EstimatedStandardizationTime__c])) THEN
set @brasilDateTime = DateAdd([Task:What:Case:EstimatedStandardizationTime__c],'-3','H')
set @date = Format(@brasilDateTime,"dd/MM")
set @hour = Format(@brasilDateTime,"HH:mm")
set @phrase2= concat("The forecast is that until", " ", @hour, " ","of day", " ", @date, " ", "will be solved.")
    set @phrase= @phrase2
else
   set @phrase= @phrase1

endif

]%%

%%=v(@phrase)=%%
1
  • So Thanks @Swati!
    – João
    Commented Oct 23, 2020 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .