Forum Discussion

lorinda_abey's avatar
lorinda_abey
Copper Contributor
Feb 06, 2024

Approval Status field to turn red when status is Pending AND file was Modified 30 days ago (or more)

I have a document library in SharePoint that has approval flows set up. However some approvers are not responding within the 30 day limit and flows are timing out.

 

To make it clear which file approvals have timed out, I would like to create a formula that will turn the text under the "Approval Status" column red for any file that has a status of "Pending" AND was modified 30 days ago (or more).

 

Can anyone help?

  • lorinda_abey Try using JSON column formatting for your Approval Status column like: 

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "color": "=if(@currentField=='Pending' && [$Modified] < addDays(@now,-30),'red','')",
        "font-weight": "=if(@currentField=='Pending' && [$Modified] < addDays(@now,-30),'bold','')"
      }
    }

     

    Where [$Modified] is an internal name of your modified date column in SharePoint list in this format: [$InternalNameOfColumn]. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?

    Output


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

  • lorinda_abey Try using JSON column formatting for your Approval Status column like: 

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "color": "=if(@currentField=='Pending' && [$Modified] < addDays(@now,-30),'red','')",
        "font-weight": "=if(@currentField=='Pending' && [$Modified] < addDays(@now,-30),'bold','')"
      }
    }

     

    Where [$Modified] is an internal name of your modified date column in SharePoint list in this format: [$InternalNameOfColumn]. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?

    Output


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • lorinda_abey's avatar
      lorinda_abey
      Copper Contributor
      Thank you. This worked perfectly.

      Question... Can you also colour a whole row (rather than just the current field) this way?
      • ganeshsanap's avatar
        ganeshsanap
        MVP

        lorinda_abey 

         

        Yes, but you will have to use the SharePoint "view" formatting with additionalRowClass for that. 

         

        Check: SharePoint List layout customizations 


        Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources