Skip to main content

Notifications

Power Automate - Building Flows
Suggested answer

Multiple formatdatetime(triggerOutputs() not working

(0) ShareShare
ReportReport
Posted on by 14
Hi All,
 
I have a flow that is working with multiple 'formatdatetime(triggerOutputs()' when they are ALL filled out on the Plumsail form, but when I leave out/don't fill in one date the flow fails to work. 
 
The message I receive is as follows: 
InvalidTemplate. Unable to process template language expressions in action 'Start_document_generation_process_with_json' inputs at line '0' and column '0': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'
 
The expression I am using for each date/time is: 
 
formatDateTime(triggerOutputs()?['body/EOWD'],'D')
 
But varies depending on each date/time.
 
I have tried applying an 'Initialize Variable' string type but I think I must have been doing it wrong. 
 
Would anyone be able to help me resolve this issue? 
 
Kind regards,
 
  • Multiple formatdatetime(triggerOutputs() not working
     
    Since it is required '' will not work as an output.  You will need to use a default value that will be accepted.  
     
    Even if it is not required, the format of '' may not be a acceptable input for plumsail since it is expecting a date time format.  I have used obviously out of range dates in the past when I have run into these sorts of problems.  1/1/1900 as an example.
     
    I would try an obviously good date value but out of range to see if it is an equation problem or a data type problem.
     
  • VB-08010839-0 Profile Picture
    VB-08010839-0 14 on at
    Multiple formatdatetime(triggerOutputs() not working
     
    Hi thanks for reaching out. The code you have suggested has also failed when I put it in a 'composed' action  before the 'start document generation process with json' action. 
     
    The first date input is required but the others are not.
  • Multiple formatdatetime(triggerOutputs() not working
    Are the date inputs required fields in Plumsail?
  • Multiple formatdatetime(triggerOutputs() not working
    '' does not equal null 
     
    try this
     
    if(equals(triggerOutputs()?['body/EOWD'], null), '', formatDateTime(triggerOutputs()?['body/EOWD'],'D'))
     
  • VB-08010839-0 Profile Picture
    VB-08010839-0 14 on at
    Multiple formatdatetime(triggerOutputs() not working
    @DreamCatcher My apologies I am not sure how to add this in. I have tried adding in:
     
    if(equals(coalesce(triggerOutputs()?['body/EOWD'], ''), ''), '', formatDateTime(triggerOutputs()?['body/EOWD'],'D'))
     
    in a 'compose' action before the 'start document generation process with json' and still no luck.
     
    Besides that I am unsure how to resolve this issue.
     
    Kind regards,
  • Multiple formatdatetime(triggerOutputs() not working
    Please see my previous answer.  Using an if statement.  null is not a datetime format.  Coalaese will look for 2 of the same formats and will get confused by the null format.
  • VB-08010839-0 Profile Picture
    VB-08010839-0 14 on at
    Multiple formatdatetime(triggerOutputs() not working
     @David_MA I have added in:
    coalesce(formatDateTime(triggerOutputs()?['body/EOWD'],'D'), '')
     
    as seen in the image below but I am still receiving the same message.
     
    Do I need to add in an 'Initialize Variable' for this to work?
     
  • VB-08010839-0 Profile Picture
    VB-08010839-0 14 on at
    Multiple formatdatetime(triggerOutputs() not working
    @DreamCatcher thanks for the suggestion. I have tried it by both trying to put it straight into the template data and also trying to put it into a 'compose' and it results in seeing the following message:

    InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '2' parameter(s). Please see https://aka.ms/logicexpressions#if for usage details.'.

    Any idea on why it might not work?




  • Suggested answer
    David_MA Profile Picture
    David_MA 8,929 on at
    Multiple formatdatetime(triggerOutputs() not working
    The error messages says that the value EOWD is null. To handle this, update your expression to use coalesce, which returns the first non-null value. Update it to coalesce(formatDateTime(triggerOutputs()?['body/EOWD'],'D'), '') and that should take care of the issue.
  • Multiple formatdatetime(triggerOutputs() not working
    It is failing because null is not formattable into a dateTime.
    Try this:
    if(equals(triggerOutputs()?['body/EOWD'], null), [default value if no value is provided], formatDateTime(triggerOutputs()?['body/EOWD'],'D'))

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,434

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,722

Leaderboard