Discussions

Expand all | Collapse all

Switc code from date to checkbox

  • 1.  Switc code from date to checkbox

    Posted 14 days ago
    Edited by Meagan McOlin 14 days ago

    Hello, 

    I currently have this wonderful code that color codes cells based on the due date and the actual date. However, we are now chaging this to be a due date and a checkbox if the appointment was scheduled. I would like cells to be color coded based on the following. 

    Green - Checkbox checked (due date any time)

    Yellow - Due date upcoming (and the checkbox isn't checked)

    Red - Due date is in the past (and the checkbox isn't checked)

    Could someone please help me modifiy this code? 

    var text red = "<a style=\" text-decoration: none; background: #ea4335; border-radius: 5px; color: #fff; display: inline-block; width: 160px; text-align: center; padding: 8px 20px; font: normal 700 14px/1 \"Calibri\", sans-serif; text-shadow: none; \">"&ToText(ToDays(Today()-[Appointment Needed By]))&" Days Overdue</a>";

    var text green = "<a style=\" text-decoration: none; background: #34a853; border-radius: 5px; color: #fff; display: inline-block; width: 160px; text-align: center; padding: 8px 20px; font: normal 700 14px/1 \"Calibri\", sans-serif; text-shadow: none; \">Complete</a>";

    var text yellow = "<a style=\" text-decoration: none; background: #fbbc05; border-radius: 5px; color: #fff; display: inline-block; width: 160px; text-align: center; padding: 8px 20px; font: normal 700 14px/1 \"Calibri\", sans-serif; text-shadow: none; \">"&ToDays(Today()-[Appointment Needed By])&" Days Due</a>";

    If(not(IsNull([Scheduled - Yes])),$green,
    If(IsNull([Scheduled - Yes]) and [Appointment Needed By] >= Today(),$yellow,
    If(IsNull([Scheduled - Yes]) and [Appointment Needed By] < Today(),$red)))


    THANK YOU!



    ------------------------------
    Meagan McOlin
    ------------------------------


  • 2.  RE: Switc code from date to checkbox

    Posted 14 days ago
    Meagin,

    It looks like a simple change from what you have posted:

    If(not(IsNull([Scheduled - Yes])) and [Checkbox]=false, $green,  .....

    In this example  [Checkbox] is the field that your users have set.


    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 3.  RE: Switc code from date to checkbox

    Posted 14 days ago

    Don,

    Thank you so much for your response. I replaced the field with [Checkbox] but it says that the field is not identified. 

    Here is a snip of the table itself. 

    Any assistance you could provide would be greatly appreciated. 

    Thank you!



    ------------------------------
    Meagan McOlin
    ------------------------------



  • 4.  RE: Switc code from date to checkbox

    Posted 14 days ago
    Use the name of the actual checkbox field.  For example if your field is called

    [Due Date Set]

    Then that is what goes into your formula.

    It could just as easily be any other name that has meaning to your users.




    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 5.  RE: Switc code from date to checkbox

    Posted 14 days ago

    Don,

    That is what I tried orginally, but I get the error below. 

    Here is the full code again if you need it: 

    var text red = "<a style=\" text-decoration: none; background: #ea4335; border-radius: 5px; color: #fff; display: inline-block; width: 160px; text-align: center; padding: 8px 20px; font: normal 700 14px/1 \"Calibri\", sans-serif; text-shadow: none; \">"&ToText(ToDays(Today()-[Appointment Needed By]))&" Days Overdue</a>";

    var text green = "<a style=\" text-decoration: none; background: #34a853; border-radius: 5px; color: #fff; display: inline-block; width: 160px; text-align: center; padding: 8px 20px; font: normal 700 14px/1 \"Calibri\", sans-serif; text-shadow: none; \">Complete</a>";

    var text yellow = "<a style=\" text-decoration: none; background: #fbbc05; border-radius: 5px; color: #fff; display: inline-block; width: 160px; text-align: center; padding: 8px 20px; font: normal 700 14px/1 \"Calibri\", sans-serif; text-shadow: none; \">"&ToDays(Today()-[Appointment Needed By])&" Days Due</a>";

    If(not(IsNull([Scheduled - Yes])),$green,
    If(IsNull([Scheduled - Yes]) and [Appointment Needed By] >= Today(),$yellow,
    If(IsNull([Scheduled - Yes]]) and [Appointment Needed By] < Today(),$red)))



    ------------------------------
    Meagan McOlin
    ------------------------------



  • 6.  RE: Switc code from date to checkbox

    Posted 12 days ago

    Don,

    Thank you for your continued help. I fixed the color-coding issue (I needed a true/false statement instead of Null) but now I am trying to code it so that the field turns yellow if the "Appointment Needed By" is coming up in 2 weeks or less. Right now it turns yellow if the date is any date less than today. We don't need it to be yellow all the time though, just when the "Appointment Needed By" date is drawing near. 



    ------------------------------
    Meagan McOlin
    ------------------------------