NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Highlight Untouched Feilds
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Highlights tasks that haven't been touched today. Requires [Date Last Modified Field]
// @author Mason Rhodes
// @match https://na51.salesforce.com/*
// @licence MIT
// @grant none
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
//Counts tickets and marks tickets that are older then 1 day blue to make them more visable in a list
function HighlightOld () {
//Required Fields
var myTable = document.getElementsByClassName("x-grid3-row");
var dates = document.getElementsByClassName("x-grid3-cell-inner x-grid3-col-CASES_LAST_UPDATE");
//Optional Fields
var closedDate = document.getElementsByClassName("x-grid3-cell-inner x-grid3-col-CASES_CLOSED_DATE");
var statusField = document.getElementsByClassName("x-grid3-col-CASES_STATUS");
//Control Variables
var len = myTable.length;
var today = new Date();
//Check if Modified Date is available (This is the minimum required field)
if (dates.length !== 0) {
//Iterate Through Tickets
for (var i = 0; i < len; i++) {
//Set Tickets Date
var ticketDate = new Date(dates[i].innerText);
var result = Math.ceil((today - ticketDate) / (1000 * 3600 * 24)) -1;
//If Difference is more then 24hrs continue.
if (result) {
//-------------------------------------------------------------------------------------------
//Checks if all optional fields are null.
if (closedDate.length === 0 && statusField.length === 0) {
myTable[i].style.background = "lightblue";}
//Checks That Closed Date isn't a null array then checks that each iteration has a value
else if (closedDate.length !== 0 && closedDate[i].innerText < 1) {
myTable[i].style.background = "lightblue";
}
//Checks that Status Field exists then checks that value isn't "Resolved"
else if (statusField.length !== 0 && statusField[i].innerText != "Resolved") {
myTable[i].style.background = "lightblue";
}
//-------------------------------------------------------------------------------------------
//Else Ignore Row
}
}//End For
}//End Last Modified
}
waitForKeyElements ("div.x-grid3-row", HighlightOld);