Display Status Indicator(Red/Green Indicators) on SharePoint List view

Display Status Indicator(Red/Green Indicators) on SharePoint List view:

Create a list called "Expiration Status" with below columns

1. Expiration Date - Date Time

2. Today - String  -- This needs to be deleted once the below calculated field is created. We are creating this column as the SharePoint does not allow us to use Today in Calculated field

3. Color - Calculated Column



4. Status - Calculated Column



Add a Content Editor Web part to to the page and add the below script:

<script type="text/javascript">
var theTDs = document.getElementsByTagName("TD");
var i=0;
var TDContent = " ";
while (i < theTDs.length) {
try {
TDContent = theTDs[i].innerText || theTDs[i].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTDs[i].innerHTML = TDContent;
}
}
catch(err){}
i=i+1;
}</script>

Save the page then list view should look like below


Done!!!!

Comments

Popular posts from this blog

Create and Deploy custom copilot to SharePoint Site (Part 2)

Create and Deploy custom copilot to MS Teams and SharePoint Site (Part 1)

Copilot Announcements from Microsoft Build 2024