Skip to main content

Notifications

Community site session details
Power Automate - Building Flows
Answered

Flow failing due to 'Null' value

Like (2) ShareShare
ReportReport
Posted on 11 Sep 2017 08:21:47 by

I have a flow setup to create a Trello card upon creation of a Sharepoint list item. One of the items I'm putting into the card's description is a date and time value from the Sharepoint list item. I am using a utcnow() function inside a compose step before the card creation step so I can inser the time and date value as a formatted string. See below:

 

 

if(equals(triggerBody()?['Due_x0020_Date'],null),'',formatDateTime(addHours(utcNow(triggerBody()?['Due_x0020_Date']),8),'yyyy-MM-dd | HH:mm'))

 

 

This works fine if someone enters a value for the date when submitting a new Sharepoint list item. However, if they don't the flow will fail with the following error:

 

Unable to process template language expressions in action 'Due_Date' inputs at line '1' and column '2112': 'The template language function 'utcNow' expects its parameter to be of type string. The provided value is of type 'Null'.

 

So, I've tried adding an if() statement to deal with possible null values but can't seem to get it working. I've tried the following unsuccessfully (all provide the exact same error if no value is entered in the 'Due_Date' field when the new items is submitted):

 

 

if(equals(triggerBody()?['Due_x0020_Date'],null),'',formatDateTime(addHours(utcNow(triggerBody()?['Due_x0020_Date']),8),'yyyy-MM-dd | HH:mm'))
if(equals(triggerBody()?['Due_x0020_Date'],Null),'',formatDateTime(addHours(utcNow(triggerBody()?['Due_x0020_Date']),8),'yyyy-MM-dd | HH:mm'))
if(equals(triggerBody()?['Due_x0020_Date'],'Null'),'',formatDateTime(addHours(utcNow(triggerBody()?['Due_x0020_Date']),8),'yyyy-MM-dd | HH:mm'))
if(empty(triggerBody()?['Due_x0020_Date']),'',formatDateTime(addHours(utcNow(triggerBody()?['Due_x0020_Date']),8),'yyyy-MM-dd | HH:mm'))
if(empty(triggerBody()?['Due_x0020_Date'],'text',formatDateTime(addHours(utcNow(triggerBody()?['Due_x0020_Date']),8),'yyyy-MM-dd | HH:mm'))

 

if(equals(triggerBody()?['Due_x0020_Date'],Null),'text',formatDateTime(addHours(utcNow(triggerBody()?['Due_x0020_Date']),8),'yyyy-MM-dd | HH:mm'))

 

 

 

What am I doing wrong?

  • leeboygp Profile Picture
    15 on 18 Sep 2023 at 12:59:43
    Re: Flow failing due to 'Null' value

    This solution did not work for me. while it handles Null values very well, even when the date column IS NOT NULL, it returns a Null value.  I'm still stuck on this. very frustrating stuff.

  • DeeTronSEAM Profile Picture
    396 on 02 Nov 2022 at 19:58:35
    Re: Flow failing due to 'Null' value

    @gauthierje ,

     

    In theory, I would think it should work. I do know that I have a flow that occasionally errors out with a null exception due to the user failing to actually attach files.  We decided that it's so rare that it isn't a high priority to put error handling in place to deal with that, so I don't know what attribute in the trigger inputs you need to zero on.  Plus, for our purposes, we know we do want the flow to run so that we can handle the situation by emailing the submitter to warn them that what they thought they submitted didn't get submitted (e.g. "Subject: Hello, Dum8@$$, you didn't attach any file with your recent Forms submission").

     

    tldr?  YMMV but probably you can make that work.

  • gauthierje Profile Picture
    3 on 02 Nov 2022 at 19:31:49
    Re: Flow failing due to 'Null' value

    Would this work with Files?  I have a flow where I give the user the opportunity to upload/attach up to two files.  However I am getting these errors if one or both potential file uploads are left blank.  

  • DeeTronSEAM Profile Picture
    396 on 27 Sep 2021 at 21:22:07
    Re: Flow failing due to 'Null' value

    HI @REISharepoint ,

     

    I'm not sure I understand what your trying to do perfectly, but feel free to clarify if the following info is not valid for your goals.

     

    1) If you want the flow to NOT run when a particular SharePoint column is null, you can put the following expression in the flow's trigger's "trigger condition" setting:

    @if(
     equals(
     coalesce(
     body('Get_Course_record_by_Course_ID')?['TheShPtColumnYouWantToExamineForNull']
     , 'ITISNULL'
     )
     , 'ITISNULL'
     )
     , false
     ,true
    )
     
    Here is an article on trigger conditions if you're not familiar with them:
     
    Note that they have an example expression that directly compares to null, and if that works, that's more elegant than my method above.  But in T-SQL that wouldn't work, so my days as a SQL Developer has me gunshy about null comparisons. Hence the Coalesce function.
     
    2) For this part of your statement, I'm confused:
     

    @REISharepoint wrote:

    I have a column in SharePoint list Training link, i am trying to write a expression where i want to skip the flow to run where the column value is NULL and then check the below expression and proceed the next step:

    @Anonymous(contains(body('Get_Course_record_by_Course_ID')?['Training_x0020_Link'],toLower('Moodle')),
    contains(body('Get_Course_record_by_Course_ID')?['Training_x0020_Link'],toLower('HRClassRoom')))

     

    Can you help me with the expression how can i write this.. maybe if condition expression


    If you want the trigger condition to ALSO check those values but only run the flow when the 'Training_x0020_Link' column contains "moodle" or "hrclassroom"  you can just add the expression you provided (in your post) as a second trigger condition  for the trigger.  The combo of those two conditions would allow the flow to only run when the 'TheShPtColumnYouWantToExamineForNull' column is NOT null, AND the Training_x0020_Link column contains either of your desired values.  If you wanted to, you could condense both expressions into a single expression and use only one trigger condition.  But this is probably easier to understand/read than what a combined expression would look like.
     
    Another option is to put all the column-value checking in a "Condition" action as the very first action in your flow, then put a Terminate action as the "Yes" or "No" result (depending on how you configure the Condition's evaluation parameter).  This method means the flow will always run to at least the first step, and thus have an entry in the flow's log.  Using the Trigger method prevents the flow from showing up in the log as it never was considered "triggered" or run.
     
    Does that help?  If not, please help me to understand better.  Good luck
  • REISharepoint Profile Picture
    2 on 27 Sep 2021 at 20:02:53
    Re: Flow failing due to 'Null' value

    I have a column in SharePoint list Training link, i am trying to write a expression where i want to skip the flow to run where the column value is NULL and then check the below expression and proceed the next step:

    @Anonymous(contains(body('Get_Course_record_by_Course_ID')?['Training_x0020_Link'],toLower('Moodle')),
    contains(body('Get_Course_record_by_Course_ID')?['Training_x0020_Link'],toLower('HRClassRoom')))

     

    Can you help me with the expression how can i write this.. maybe if condition expression

  • DeeTronSEAM Profile Picture
    396 on 16 Sep 2020 at 07:02:05
    Re: Flow failing due to 'Null' value

    WHAT a PITA!!!!

     

    But shoutout to @andrew_blubase for alleviating some of the pain with his workaround.  Thanks, Andrew!

  • TechIY Profile Picture
    42 on 04 Sep 2020 at 14:13:22
    Re: Flow failing due to 'Null' value

    Awesome! Thank you Andrew - evergreen solution

  • Kaarthi Profile Picture
    4 on 10 Aug 2020 at 10:44:47
    Re: Flow failing due to 'Null' value

    Thanks Andrew, It works, Fantastic...

  • vsolanon Profile Picture
    146 on 28 Jun 2020 at 21:41:03
    Re: Flow failing due to 'Null' value

    Thank you @andrew_blubase! This is what I was looking for 🙂

     

    I applied your formula and it worked like a charm!

  • Community Power Platform Member Profile Picture
    on 15 Oct 2019 at 08:38:37
    Re: Flow failing due to 'Null' value

    Hi @v-monli-msft  may i ask in case you know, why i cannot access  (i am getting an access denied)

    https://powerusers.microsoft.com/t5/Microsoft-Flow-Knowledge-Base/How-to-check-if-a-field-is-blank/ta-p/31843  ?

    Thanks in advance

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,079 Most Valuable Professional

Leaderboard