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

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 &amp;lt; today</label> </field> <field id="AssistantName" valuehalign="" type=""> <label>Render if birthdate &amp;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>

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 :slight_smile: 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?

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.

Whew! Thanks for the reply despite the bad news. I was beginning to wonder what was happening and had a sneaking suspicion that this was a tricky one given the date literals in Salesforce run in SOQL on the server and Skuid would not be able to use the same logic for client-side conditional rendering without re-implementing its own date literal logic. As you said the good news is that you’re on to this but in the meantime the page builder makes it look like it’s possible to do this which can confuse and mislead users when they try to figure out what is wrong with their page. Perhaps you could disable or hide the date literal options for now.

Right now my only workaround is to use custom renderers and code. I almost got it working with a UI-only formula field using date literals but encountered some other unusual Skuid behaviours where UI-only date formula fields didn’t trigger conditional render evaluation so I tried to work around that with an actual field and it sort of worked but not when the date field starts off as empty…have attached the almost working page in case Skuid or anyone else can figure it out. If you trigger the model change by setting the empty date field to after today and then back to before today it all starts working, very strange…)

<skuidpage unsavedchangeswarning="" 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"/> <field id="Fax"/> <field id="BirthdateRenderFlag" uionly="true" displaytype="FORMULA" label="BirthdateRenderFlag" readonly="true" returntype="TEXT"> <formula>(TODAY() - {{Birthdate}}) &amp;lt; 0</formula> </field> <field id="HasOptedOutOfFax" overridemetadata="false" ogdisplaytype="BOOLEAN" displaytype="BOOLEAN" defaultValue="true"/> </fields> <conditions/> <actions/> </model> </models> <components> <basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="contact" buttonposition="" uniqueid="ConditionalRenderFieldEditor" mode="edit" layout=""> <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 &amp;lt; today</label> </field> <field id="AssistantName" valuehalign="" type=""> <label>Render if birthdate &amp;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="Fax" valuehalign="" type=""> <label>Render if TODAY - birthdate &amp;gt; 0 (workaround)</label> <renderconditions logictype="or" onhidedatabehavior="keep" logic="2"> <rendercondition type="fieldvalue" operator="=" enclosevalueinquotes="true" fieldmodel="contact" sourcetype="fieldvalue" field="BirthdateRenderFlag" value="true"/> <rendercondition type="fieldvalue" operator="=" enclosevalueinquotes="false" fieldmodel="contact" sourcetype="fieldvalue" field="HasOptedOutOfFax" value="true"/> </renderconditions> <enableconditions logictype="and"/> </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> <field id="BirthdateRenderFlag" valuehalign="" type=""/> <field id="HasOptedOutOfFax"/> </fields> </section> </sections> </column> </columns> <renderconditions logictype="and"/> </basicfieldeditor> </components> <resources> <labels/> <javascript> <jsitem location="inline" name="InLine" cachelocation="false" url="">(function(skuid){ var $ = skuid.$; $(document.body).one('pageload',function(){ skuid.events.subscribe('row.updated', function(updateResult) { var contactModel = skuid.$M("contact"); if ((updateResult.modelId === contactModel.id) &amp;amp;&amp;amp; (updateResult.rowId === contactModel.getFirstRow().Id)) { updateResult.row.HasOptedOutOfFax = updateResult.row.BirthdateRenderFlag; } }); }); })(skuid);</jsitem> </javascript> <css/> </resources> <styles> <styleitem type="background" bgtype="none"/> </styles> </skuidpage> 

Bummed to find this thread! But at least it stops me from wasting more time trying to figure out why the all the date data is correct but the condition is failing.

Did you get your workaround to function?

Probably stating something you already know,

But why not use Salesforce Formula Fields to accomplish the Same?
Then simply make condition based on that field

In your case example If(TODAY() - Birthdate < 0,1,0)
And render if = 1 or whatever your use case is.

Unless ofc you are trying to do this on 2 date fields from 2 completely unrelated child records… 

We got our workaround working because with javascript we have complete control over the date calculation and field rendering but it is more work. We couldn’t use formula fields because we needed the conditional rendering to occur as soon as the date is entered or changed and we did not want to save (the possibly new record yet) and then re-query the record from Salesforce to get the re-calculated formula field. Apart from the delay it can also have undesirable side effects with other trigger or workflow logic fired on the record insert/update which we didn’t want.

Thanks for the info, good to hear how other people are making things work.

My case is simpler: if (deadline date) >= today then render wrapper A, if (deadline date) < today then render wrapper B. It’s purely a presentation requirement so unfortunate to muddy the CRM data model with a field for this. Especially when Skuid is set up to do exactly what I need, if it worked. Hopefully soon!?

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


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?

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

Bad news :frowning:

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



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.

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