SOLVED

Change text field depending on what day of the week it is

Copper Contributor

Afternoon,

 

Is it possible to setup a text field on sharepoint that changes the text depending on what day of the week it is?

 

Thanks

7 Replies

@Jamie Lawrence You can try using WEEKDAY function and create a calculated column to show the text based on day of the week.

For example: 

=IF(WEEKDAY([Start Date]) = 1, "Sunday", IF(WEEKDAY([Start Date]) = 2, "Monday", IF(WEEKDAY([Start Date]) = 3, "Tuesday", IF(WEEKDAY([Start Date]) = 4, "Wednesday", IF(WEEKDAY([Start Date]) = 5, "Thursday", IF(WEEKDAY([Start Date]) = 6, "Friday", "Saturday"))))))

ganeshsanap_0-1668673965016.png


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.

best response confirmed by Jamie Lawrence (Copper Contributor)
Solution

@Jamie Lawrence I read your question slightly differently to @ganeshsanap and it seemed to me you might be wanting to do something similar to what we do on our intranet where there is a message or reminder about somethinbg every day. A few senior staff go into a list and change the message, and at 2am every day a flow runs in Power Automate that updates a different list which has just 1 item in it which is the message of the day. That message is then displayed on the homepage of the intranet, formatted with JSON to make it look better than the standard view of the list.

 

This is the list where the messages are stored:

0-SP-Messages.png

This is the flow:

 

1-Flow.png

 and then gets the item for that day from the messages list:

2-Flow.png

 
The flow then updates the other list with the message for that day:

3-Flow.png

 

And this is the result which is displayed on the homepage with the list web part:

4-SP-Result.png

The JSON view formatting for this is as follows and is based on the Announcements view formatting at https://github.com/pnp/List-Formatting/tree/master/view-samples/announcements

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "hideColumnHeader": true,
  "hideSelection": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "min-width": "15vw",
      "max-width": "19vw",
      "padding-bottom": "20px"
    },
    "customCardProps": {
      "formatter": {
        "elmType": "div",
        "children": [
          {
            "elmType": "img",
            "attributes": {
              "src": "[$Image]"
            }
          }
        ],
        "style": {
          "height": "200px",
          "width": "200px",
          "cursor": "pointer",
          "font-size": "14px",
          "padding": "14px",
          "align-items": "stretch"
        }
      },
      "openOnEvent": "hover",
      "directionalHint": "leftCenter",
      "isBeakVisible": false,
      "beakStyle": {
        "backgroundColor": "white"
      }
    },
    "children": [
      {
        "elmType": "div",
        "style": {
          "border-radius": "8px",
          "box-shadow": "#00000022 0px 1.6px 3.6px 0px, #00000022 0px 0.3px 0.9px 0px",
          "display": "flex",
          "font-size": "1rem",
          "background-color": "#e5f6fd",
          "line-height": "1.43",
          "padding": "6px 16px",
          "align-items": "center",
          "flex-flow": "wrap"
        },
        "children": [
          {
            "elmType": "span",
            "attributes": {
              "iconName": "info"
            },
            "style": {
              "padding-right": "10px",
              "font-weight": "700",
              "color": "#03a9f4"
            }
          },
          {
            "txtContent": "[$Title]",
            "elmType": "div",
            "style": {
              "font-weight": "700",
              "margin-bottom": "0.35em"
            }
          },
          {
            "elmType": "div",
            "txtContent": "[$Message]",
            "style": {
              "padding-left": "26px",
              "flex-direction": "column"
            }
          }
        ]
      }
    ]
  }
}

 

I hope that's useful.

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

 

Thanks for this Rob, this is exactly what i was looking for. I will give it a go and see how i get on
Hi Rob,

Apologies but I am having trouble with the JSON setting on the list. I copied and pasted the one you used but it doesn't change anything and the view stays the same. Is there something else I need to change to apply this? Thanks for your help

@Jamie Lawrence make sure you are using YOUR column names in the list, that is the column name between [$ and ]

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

So I created the same table as you using Title and Message, do you have any any other columns in that table which I may of missed?
1 best response

Accepted Solutions
best response confirmed by Jamie Lawrence (Copper Contributor)
Solution

@Jamie Lawrence I read your question slightly differently to @ganeshsanap and it seemed to me you might be wanting to do something similar to what we do on our intranet where there is a message or reminder about somethinbg every day. A few senior staff go into a list and change the message, and at 2am every day a flow runs in Power Automate that updates a different list which has just 1 item in it which is the message of the day. That message is then displayed on the homepage of the intranet, formatted with JSON to make it look better than the standard view of the list.

 

This is the list where the messages are stored:

0-SP-Messages.png

This is the flow:

 

1-Flow.png

 and then gets the item for that day from the messages list:

2-Flow.png

 
The flow then updates the other list with the message for that day:

3-Flow.png

 

And this is the result which is displayed on the homepage with the list web part:

4-SP-Result.png

The JSON view formatting for this is as follows and is based on the Announcements view formatting at https://github.com/pnp/List-Formatting/tree/master/view-samples/announcements

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "hideColumnHeader": true,
  "hideSelection": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "min-width": "15vw",
      "max-width": "19vw",
      "padding-bottom": "20px"
    },
    "customCardProps": {
      "formatter": {
        "elmType": "div",
        "children": [
          {
            "elmType": "img",
            "attributes": {
              "src": "[$Image]"
            }
          }
        ],
        "style": {
          "height": "200px",
          "width": "200px",
          "cursor": "pointer",
          "font-size": "14px",
          "padding": "14px",
          "align-items": "stretch"
        }
      },
      "openOnEvent": "hover",
      "directionalHint": "leftCenter",
      "isBeakVisible": false,
      "beakStyle": {
        "backgroundColor": "white"
      }
    },
    "children": [
      {
        "elmType": "div",
        "style": {
          "border-radius": "8px",
          "box-shadow": "#00000022 0px 1.6px 3.6px 0px, #00000022 0px 0.3px 0.9px 0px",
          "display": "flex",
          "font-size": "1rem",
          "background-color": "#e5f6fd",
          "line-height": "1.43",
          "padding": "6px 16px",
          "align-items": "center",
          "flex-flow": "wrap"
        },
        "children": [
          {
            "elmType": "span",
            "attributes": {
              "iconName": "info"
            },
            "style": {
              "padding-right": "10px",
              "font-weight": "700",
              "color": "#03a9f4"
            }
          },
          {
            "txtContent": "[$Title]",
            "elmType": "div",
            "style": {
              "font-weight": "700",
              "margin-bottom": "0.35em"
            }
          },
          {
            "elmType": "div",
            "txtContent": "[$Message]",
            "style": {
              "padding-left": "26px",
              "flex-direction": "column"
            }
          }
        ]
      }
    ]
  }
}

 

I hope that's useful.

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

 

View solution in original post