cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
risingson
Advocate I
Advocate I

Flow failing due to 'Null' value

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?

22 REPLIES 22
DeeTronSEAM
Advocate V
Advocate V

WHAT a PITA!!!!

 

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

REISharepoint
New Member

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:

@OR(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

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:

@OR(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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,327)