Oct 03 2020 10:16 AM - edited Oct 04 2020 12:15 AM
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 😃
Oct 04 2020 07:10 AM
Hi @Tonje Waasjø,
I'm not sure it's possible without using a Condition or a replacement date (when null).
Norm
Oct 04 2020 12:45 PM
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.
Dec 28 2023 02:16 PM
@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:
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.