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?
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.
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.
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.
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
)
@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
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
WHAT a PITA!!!!
But shoutout to @andrew_blubase for alleviating some of the pain with his workaround. Thanks, Andrew!
Awesome! Thank you Andrew - evergreen solution
Thanks Andrew, It works, Fantastic...
Thank you @andrew_blubase! This is what I was looking for 🙂
I applied your formula and it worked like a charm!
Hi @v-monli-msft may i ask in case you know, why i cannot access (i am getting an access denied)
Thanks in advance
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional