Select to view content in your preferred language

Ability to return only change fields when update is made

374
7
4 weeks ago
Status: Open
JustPete
Regular Contributor

One of the issues with automated emailing using Power Automate and When a Record is Updated trigger is that there is no way to filter the field that is being changed. This is problematic when trying to create a host of automated emails relating to a single feature layer to notify users when certain changes are happening.

What would be really useful is the ability to use a logical function to select the field that is being changed to then feed into the action. For example, Send email IF field/ProjectManager is updated, rather than Send email when Feature Layer is updated, since not all fields that are updated require automated email notifications. 

7 Comments
Tiff
by

I 100% agree with this that this is much needed functionality. I have a Power Automate flow that sends out up to four emails at a time based on four fields and because the trigger recognizes all changes, I had to find a very complex workaround using dates in the field and date time of edit to accomplish this, which is not foolproof.

JustPete

One way I'm trying to find a resolve is when attributes are changed and there is an associated date field, having an IF datefield = utcNow() then that will prompt the email.

Tiff
by

Did you have any luck with that workaround? I ask because, I actually ran into a couple issues with the date time condition and I'm curious if it worked for you. There were two issues, firstly:

1. The date field may never match with utcNow (unless you make it just date and not time, in which any edit that same day will probably trigger the email again). 

2. Date and time condition has an issue because the ArcGIS feature layer trigger can take up to 5-6 minutes to trigger. In my flow I set a condition for a 6 minute buffer window so that emails are only sent out within that window, and if the date field is over a 6 minute difference from the time the trigger ran, then no emails are sent.

JustPete

Yes, initial testing today and shown it to work. I'm working off a feature layer with over 250 fields and around 300 rows. Sometimes the flows can break if there is too much data for the trigger to filter, so many be worth, if you have a large amount of data, to filter down using the 'Get data from feature layer" action, and using the available fields and where function. 

In order for the date and time function to work, there are a few things that need to happen. 

1. You need 3 loops after the trigger. The first being to fetch updates, changes etc from the 'When record is updated' trigger. 

2. A loop immediately after the fetch updates which will be used to convert the date and time field, since Power Automate can't read feature layer fields as date and time. Then within that loop, you need to convert the time into date only using compose. The function loops like this: 

formatDateTime(outputs('Convert_Option_and_Lease_date_signed_and_time_format')?['body/stringTime'], 'yyyy-MM-dd')
 
3. The final loop for the conditions. In this case, I'm only interested where Option and Lease is Signed and the Signing date is today: 
{
  "type": "If",
  "expression": {
    "and": [
      {
        "equals": [
          "@items('Loop_in_for_Option_and_Lease_condition')?['Attributes/OptionandLeaseStatus']",
          "Signed"
        ]
      },
      {
        "equals": [
          "@outputs('Compose_Option_and_Lease_Date_signed')",
          "@utcNow('yyyy-MM-dd')"
        ]
      }
    ]
  },
For the testing of "today", you would have feature being "compose outputs" is equal to 
utcNow('yyyy-MM-dd'). It's important to have the utcNow converted to just show date, otherwise it will use time as well and cause the condition to see if the compose date matches the now date and time, which will cause the flow to fail. 
 
Other than that, I can't see any other work around until there is the ability to have an action to only return the changed attribute. There is a potential work around, without the need to have a date field associated with the change field, but that involves having Power Automate access the change log, produce the original data and changed data fields and comparing.
 
Hope this helps.
JustPete_0-1748002183887.png

 

Tiff
by

Very informative, thank you!! I like how you mentioned the get data action since that could have streamlined the flow a bit more.

So that I'm understanding - the biggest limitation of the workaround you found is that once the date is set to today's date and the flow is run & email is sent, etc. that record should not be edited again in that same day, correct? If it's edited again, then the email will send out again redundantly? 

JustPete

You're welcome.

Yes, that's correct. Although I wouldn't say that would be an issue, since it would allow users to be made aware of changes on an Adhoc basis. What you could do instead is use the standard utcNow() and date field, without converting them to date only, and using that in the condition. Then users would be able to change the attribute without an email being sent, if the date field associated with the change field isn't updated.

Tiff
by

Thanks @JustPete! In our use case, our email notifications only play a role when the process reaches a certain few checkpoints - sending automated notifications to leadership. As a result, it was really important for us to ensure that emails were only sent when necessary, so again pointing back to your idea being very important on only returning change fields!