Check if date field from MS Forms is empty in Power Automate

Brass Contributor

I have a flow that triggers when a new Forms response is submitted. In the form, it is a date field that is not required. In my flow, I put all the fields from the form into a SharePoint list. If that datefield is empty, the flow fails. 

Do any of you know what test I can do in the Expression for the field so I don't get an error? I do not want to use a Condition because I have too many of them already =)

3 Replies

Hi @Tonje Waasjø,

 

I'm not sure it's possible without using a Condition or a replacement date (when null).

 

Norm  

Hey @Tonje Waasjø , in my opinion you dont need an expression, you can insert a Variable Action.

 

Before the SharePoint action create a parallel branch to catch an error with empty date field in the first branch. That is much easier to deal with isEmpty() validations on fields.

 

So the second branch can catch the next action in case the first branch erros out: create a string variable, because the Date Field in MS Forms will be seen as an integer value, and sharepoint can then get it as an emply text content without an error, so are my ideas on this.

 

Hope that helps, Eva.

 

 

@Tonje Waasjø SharePoint actions like "Create Item" are funny because while you can use the expression "null" to clear data from a date field, or simply leave a date field blank (in which case it will end up null), you will get an error if you try to pass a null value into the action, such as from a variable or a Forms response.

 

So what you can do is use an "If" expression to evaluate the date value received from Forms:

  • If the date value is found to be empty, use null
  • Otherwise, use the value from Forms

 

Neil425_0-1703800765867.png

 

The expression in the screenshot is:

if(equals(variables('varFormsDate'),''),null,variables('varFormsDate'))

 

Here "varFormsDate" is a string variable that has been set to the date value from Forms. You don't have to set a variable first, you can work directly with the value received from Forms if you prefer, but it does make expressions a little easier to read =)

 

FYI this approach also works with other types of columns that are finicky about receiving null values, like URL columns.