Forum Discussion

SZLK85's avatar
SZLK85
Copper Contributor
Jan 25, 2023

Send email notification when calculated field value changes

Hello,   I have a Sharepoint list with a Date field and a Calculated field. The Calculated field calculates the difference between the Date field and NOW() (in days).   So when this calculation ...
  • SvenSieverding's avatar
    Jan 25, 2023

    Hi SZLK85 

    a calculated column in SharePoint does only update if you update the item itself. If you want to dynamically display the remaining days then use this formatting sheet on your date column

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "=floor((Number(@currentField)-Number(Date((getMonth(@now)+1)+'.'+getDate(@now)+'.'+getYear(@now))))/(60*60*24*1000))+' day(s) remaining'"
    }

     


    You can create a new scheduled flow that runs every day at a certain time.
    Then calculate in a variable "30DaysIntheFuture" the date 30 days in the future

    convertToUtc(startOfDay(addDays(convertTimeZone(utcNow(),'UTC','W. Europe Standard Time'),30)),'W. Europe Standard Time')


    Now use a "Get items" from SharePoint action for your list and set the "Filter Query" to

    YourDateField eq datetime'@{variables('30DaysIntheFuture')}'


    As a result you have all the items where the value of your date column is 30 days in the future.
    Now send a Mail for each result.

    This works if you just have a "Date" field. If you did include the time in your column, then we need to create two variables (One 30 in the future and one 31 days in the future) and check if the column value ist between these two dates.


    Best Regards,
    Sven




Resources