Conditional rendering using date literals always evaluates as true (Banzai 7.19)

  • 3
  • Problem
  • Updated 2 years ago
  • Acknowledged
We want to conditionally display a field when another (date) field is less than today (and other date literals). When using the conditional rendering feature to do this the condition always returns true no matter what date literal we use. If you use simple not null or specific date string is works fine. This was not working on 6.8.19 so we tried 7.19 and it still doesn't work. Is there something we're doing wrong? Have attached a simple page to replicate the issue:

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" showheader="false">
   <models>
      <model id="contact" limit="1" query="true" createrowifnonefound="false" adapter="" type="" doclone="" sobject="Contact">
         <fields>
            <field id="AssistantName"/>
            <field id="Birthdate"/>
            <field id="Name"/>
            <field id="AssistantPhone"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
   </models>
   <components>
      <basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="contact" buttonposition="" uniqueid="sk-16d78x-198" mode="edit">
         <columns>
            <column width="100%">
               <sections>
                  <section title="" collapsible="no" showheader="false">
                     <fields>
                        <field id="Name" valuehalign="" type=""/>
                        <field id="Birthdate" valuehalign="" type="">
                           <label>BirthDate - try setting to '2015-11-26' and &lt; today</label>
                        </field>
                        <field id="AssistantName" valuehalign="" type="">
                           <label>Render if birthdate &lt; TODAY date literal (but doesn't work?) </label>
                           <renderconditions logictype="and" onhidedatabehavior="keep">
                              <rendercondition type="fieldvalue" operator="lt" enclosevalueinquotes="false" fieldmodel="contact" sourcetype="fieldvalue" field="Birthdate" value="TODAY"/>
                           </renderconditions>
                           <enableconditions/>
                        </field>
                        <field id="AssistantPhone" valuehalign="" type="">
                           <label>Render if birthdate = '2015-11-26' specific date (works)</label>
                           <renderconditions logictype="and" onhidedatabehavior="keep">
                              <rendercondition type="fieldvalue" operator="=" enclosevalueinquotes="false" fieldmodel="contact" sourcetype="fieldvalue" field="Birthdate" value="2015-11-26"/>
                           </renderconditions>
                           <enableconditions/>
                        </field>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
   </components>
   <resources>
      <labels/>
      <javascript/>
      <css/>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>
Photo of Stephen Chan

Stephen Chan

  • 956 Points 500 badge 2x thumb

Posted 3 years ago

  • 3
Photo of Stephen Chan

Stephen Chan

  • 956 Points 500 badge 2x thumb
Can anyone from Skuid let me know what is happening with this issue? I think I've been spoilt by the prompt response from community support in the past but after 6 days I'm beginning to worry :-) Have we done something wrong here or is there a workaround other than to write javascript to manually do our own date calculations to do conditional rendering?
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Hey Stephen, sorry for the delayed response.  Unfortunately Date Literals don't work with conditional rendering at this time :'( 
The good news is that this is one of the higher priority items on our list. We'll let you now when there's a fix, and any workarounds that come to our attention.
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
John,

Good news, I believe i can fix your problem

I just had an idea and tested it out, and it worked

If u break down the day , month and year of date in the formula you can accomplish it

Create a UI only formula field with a number result

and add this formula (replace Name_of_Your_field__c by the date field you want to use)

IF((DAY({{Name_of_Your_field__c}})+1)>=DAY(TODAY()),1,0) + IF((MONTH({{Name_of_Your_field__c}}))>=MONTH(TODAY()),1,0) + IF((YEAR({{Name_of_Your_field__c}}))>=YEAR(TODAY()),1,0)

If the result = 3 it means the day, month, year >= than today

So render condition would be easy to create

Enjoy,

P.S In case you are wondering, the reason i'm adding a +1 to the day of your date, is because of a known bug in Skuid not converting properly the Day into the proper value
Photo of John Greenhill

John Greenhill

  • 472 Points 250 badge 2x thumb
Thanks for your effort, Dave! Let me make sure I'm understanding:

* Each of the three IF statements is going to return 1 or 0
* The left side of each of the 3 >= tests is extracting the number of that part of my date
* The right side is extracting the corresponding number portion of TODAY

Today is 1 - 21 - 2016. My date is 2 - 1 - 2016. Won't the day test fail and the whole formula return a value of 2, even though Feb is later than today? Or do I not understand how this works?
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
John,

* Each of the three IF statements is going to return 1 or 0 - Correct
* The left side of each of the 3 >= tests is extracting the number of that part of my date -correct
* The right side is extracting the corresponding number portion of TODAY Correct

Today is 1 - 21 - 2016. My date is 2 - 1 - 2016. Won't the day test fail and the whole formula return a value of 2, even though Feb is later than today? Or do I not understand how this work

You are correct in this, at first I was thinking, your formula scenario was if == today
and that formula works perfectly for that scenario
Once I was about to reply did i notice you needed >= today and did not think further lol

But here's another way to accomplish it, but it may not be 100% accurate

IF((DAY({{Name_of_Your_field__c}})+  (MONTH({{Name_of_Your_field__c}})*30.5)) >=(DAY(TODAY())+  MONTH(TODAY())*30.5),1,0) +IF((YEAR({{Name_of_Your_field__c}}))>=YEAR(TODAY()),1,0)

I'm basically converting the months in days and adding them up to the day

The only issue I can see with this formula is that I'm multiplying the # of Months by a static value of 30.5 (average days per month)

Could be an issue for months like Feb or small data sample

Hope it helps
(Edited)
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Bad news :(

While trying to use this on 1 of my page I realized something else
The bug of the day # returning 1 less, is a big problem when the date is on the 1st of the month.

The day returns 31..... therefore my logic to add 1 would not work
Photo of John Greenhill

John Greenhill

  • 472 Points 250 badge 2x thumb
No prob, Dave, I really appreciate your effort. 

For now I went ahead and added a formula field to the CRM and base my display logic on that. Perhaps I will clean it up in some future refactor after Skuid fixes the bug and I can use the Skuid feature.

Thanks again for your time.
Photo of Karen Waldschmitt

Karen Waldschmitt, Official Rep

  • 8,240 Points 5k badge 2x thumb
Hi Community~

This bug has been fixed in Rockaway Point Release - Iteration 8 and is now available at https://www.skuid.com/skuidreleases.

Thanks for your patience!!!
Karen