Forum Discussion

AmyTran's avatar
AmyTran
Qrew Member
3 years ago

Coding Help

Hi everyone!

I am asking for someone to help me with a formula - rich text code if possible to color code notifications. To clarify, there will be a start date and 7 days out from that date if the record/task is not completed it will be in yellow. If 10 days have passed and the task is still not completed it will be in orange and in 14 days it will be in red. If the task is completed (checkbox is checked) then the notifications will be turned off for that record. Something as shown below: 

Any and all help is greatly appreciated. Thank you & have a great day!

------------------------------
Amy Tran
------------------------------
  • Amy, I have done something similar by changing the background color of fields based on a project status. You could modify this to show the cleaner "button" look you show using the typical HTML for buttons and just not have it link to anything, but this should give you a start.

    var number DaysLeft = ToDays(Today()-[Final Report Due]);

    If($DaysLeft<-7, "<div style=\"background-color:GreenYellow;\">"&Abs($DaysLeft) & " Days Remaining"&"</div>",
    If($DaysLeft<-1, "<div style=\"background-color:Gold;\">"&Abs($DaysLeft) & " Days Remaining"&"</div>",
    If($DaysLeft=-1, "<div style=\"background-color:Orange;\">"&"Report due Tomorrow"&"</div>",
    If($DaysLeft=0, "<div style=\"background-color:Yellow; color:IndianRed;\">"&"Report due TODAY"&"</div>",
    If($DaysLeft>0, "<div style=\"background-color:white; font-size:15px; font-weight:bold; color:red\">"&"Report OVERDUE"&"</div>")))))

    It would end up looking something like this (content does not match formula excerpt above, but format does).  


    ------------------------------
    Oana Toma
    ------------------------------
    • AmyTran's avatar
      AmyTran
      Qrew Member
      Oana, 

      Thank you so much for your help! I greatly appreciate your help. The only question I have is - can there be a way for the notifications to not show if something is completed and/or checked?

      ------------------------------
      Amy Tran
      ------------------------------
      • OanaWhalen's avatar
        OanaWhalen
        Qrew Cadet
        Yes! You can just wrap it in an if statement that shows nothing if a box is checked. The "" value is what tells it to leave the field blank.

        The formula below says "If the checkmark is checked, show a blank value. Otherwise, show the colored message."

        var number DaysLeft = ToDays(Today()-[Final Report Due]);

        If([checkmark]=true,"",
        If($DaysLeft<-7, "<div style=\"background-color:GreenYellow;\">"&Abs($DaysLeft) & " Days Remaining"&"</div>",
        If($DaysLeft<-1, "<div style=\"background-color:Gold;\">"&Abs($DaysLeft) & " Days Remaining"&"</div>",
        If($DaysLeft=-1, "<div style=\"background-color:Orange;\">"&"Report due Tomorrow"&"</div>",
        If($DaysLeft=0, "<div style=\"background-color:Yellow; color:IndianRed;\">"&"Report due TODAY"&"</div>",
        If($DaysLeft>0, "<div style=\"background-color:white; font-size:15px; font-weight:bold; color:red\">"&"Report OVERDUE"&"</div>")))))
        )

        ------------------------------
        Oana Toma
        ------------------------------