Blanking out date fields in Dynamics 365 using a Flow

Dynamics 365 supports a number of base content types naively that can be set via Flow.  However, date fields are a bit finicky.  When trying to set a date field, you can provide the date in a string format.  But what do you do if you need to clear out an existing value in a date field in a Dynamics 365 record?

Turns out that the Dynamics 365 connector is not behaving the way most of us would expect.  Leaving the field blank will not change the value.  If you add any value into the date field other than a date field, the action will fail.  

The way to do it is by using the following steps:
  1. Add a Convert time zone action.  If you're not actually converting the time, then set the Source time zone and Destination time zone to be the same.
  2. Assign the Base Time you want for the field.  If you want to clear it out, set it to the null expression.  null will cause the time conversion operation to fail, but still creates a time object.
  3. In the action immediately following the Convert time zone action, set the Configure run after to run after success and failure.

You will need to do this for every date field that you may want to reset.

6 comments:

  1. @Haniel - I have tried this and it failed with below error. Can you advise me please?

    Unable to process template language expressions for action 'Convert_time_zone' at line '1' and column '2065': 'In function 'converttimezone', the value provided for date time string '' was not valid. The datetime string must match ISO 8601 format.'.

    Thanks
    Arjun

    ReplyDelete
  2. AWSOME, it worked for me in combination with Microsoft Logic Apps

    ReplyDelete
    Replies
    1. Yes, Power Automate (Microsoft Flow) is based on Logic Apps so this logic works on both platforms.

      Delete
  3. Thank you for this workaround. I have used it also in Logic Apps for resetting DateTime fields... Can't believe we need to get this dirty to make something this simple that should have been available by default.

    ReplyDelete
    Replies
    1. Like many other platforms, this is an ongoing works in progress :)

      Delete

Employee Check-in Simplified using Power Automate

Company employees who move between offices are often faced with a tedious process of having to check-in at the security desk to get a tempor...