Comparison of UI Only Date to Salesforce Date -- Not working?

Mark LMark L ✭✭✭✭
edited June 29, 2020 in Questions
I have a UI only model that allows a user to specify a date and then run a separate model query on a Salesforce Account.

As part of my query on Account I'm comparing a Date field on the Account to the UI Only Date field: AccountDate__c >= (Field From Another Model)(UIOnlyDateField)

Except that this comparison seems to not work at all. I've set the condition to always on, and even set it to abort the model's query if no row in source model, but for some reason the Account query just ignores the condition completely and returns all accounts regardless of the Date comparison.

Why is this happening? I'm running circles around both the UI editor and the XML to try and figure out what's going on and all I can see is that this is a bug; but I've done date comparisons before with UI only models and Salesforce dates and those seem to work, why here is this not working?

Any ideas? Thanks!

Comments

  • Mark DeSimoneMark DeSimone 🛠️ 
    edited June 29, 2020
    Hi Mark, 
    One possibility that comes to mind is that the UIOnly model may not have its row & value ready for the Account model condition to use. Try to make sure the Account model is loading after the UIOnly model. Maybe as a test, you can add a button to your page, and only query the account model via the button. If it works after page load is complete, then I think this timing might be the issue.
    Also, make sure the two fields are both the same type - basically, datetime and date fields are not equivalent. 
  • Mark LMark L ✭✭✭✭
    edited October 10, 2019
    Hi Mark,

    Thanks for the idea, but the field is definitely is ready prior to running the query. I even have another model querying right before the Account model that relies on this UI only date field, and  that one is working properly (date comparison works there).

    The fields are both "Date" fields.
  • edited June 29, 2020
    Can you clone then simplify the page a bit maybe and post the XML? Maybe change AccountDate__c to CreatedDate or LastModifiedDate just to make it easily testable in other orgs.
  • Mark LMark L ✭✭✭✭
    edited October 14, 2019
    I'm querying on Account; this is a Date field I'm using, not DateTime as CreatedDate / LastModifiedDate are, so best to create a custom Date field to test this. The date field I have in my code is "Board_Election_Date__c"

    image

    I've simplified the page as much as possible while keeping the same overall structure; I've even removed the other conditions in the query and left only this one condition. The bug is maintained in the simplified page. How do I go about posting code here? I'll try to post here:

    <skuidpage unsavedchangeswarning="yes"> <models> <model id="Membership_Report_Tab__ModelLoaded" limit="20" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true"> <fields> <field id="MembershipExportForBoard" displaytype="BOOLEAN" label="MembershipExportForBoard" ogdisplaytype="TEXT" picklistsource="manual" returntype="TEXT" defaultvaluetype="fieldvalue" defaultValue="false"/> <field id="AccountWithMemberDemographics" displaytype="BOOLEAN" label="AccountWithMemberDemographics" ogdisplaytype="TEXT" defaultvaluetype="fieldvalue" defaultValue="false"/> <field id="MembershipStatistics" displaytype="BOOLEAN" ogdisplaytype="TEXT" defaultvaluetype="fieldvalue" defaultValue="false"/> <field id="NSOpenBalances" displaytype="BOOLEAN" ogdisplaytype="TEXT" picklistsource="manual" returntype="TEXT" defaultvaluetype="fieldvalue" defaultValue="false"/> <field id="MensClubNewMembers" displaytype="DOUBLE" label="MensClubNewMembers" ogdisplaytype="TEXT" precision="1" scale="0" defaultvaluetype="fieldvalue" defaultValue="0"/> </fields> <conditions/> <actions/>a </model> <model id="Membership_Report_Tab__MensClubNewMembersVars" limit="20" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true"> <fields> <field id="BilledSinceDate" displaytype="DATE" label="BilledSinceDate" ogdisplaytype="TEXT" defaultvaluetype="fieldvalue"/> <field id="RunReport" displaytype="DOUBLE" label="RunReport" ogdisplaytype="TEXT" precision="1" scale="0" defaultvaluetype="fieldvalue" defaultValue="0"/> </fields> <conditions/> <actions> <action> <actions> <action type="branch" whenfinished="continue"> <formula>{{RunReport}} = 1</formula> <iftrueactions> <action type="updateRow" fieldmodel="Membership_Report_Tab__MensClubNewMembersVars" affectedrows="context"> <updates> <update valuesource="fieldvalue" field="RunReport" enclosevalueinquotes="false" value="0"/> </updates> </action> <action type="updateRow" fieldmodel="Membership_Report_Tab__ModelLoaded" affectedrows="context"> <updates> <update valuesource="fieldvalue" field="MensClubNewMembers" enclosevalueinquotes="false" value="1"/> </updates> </action> <action type="requeryModel" model="Membership_Report_Tab__MensClubNewMembersByJoinDate" behavior="standard"/> <action type="updateRow" fieldmodel="Membership_Report_Tab__ModelLoaded" affectedrows="context"> <updates> <update valuesource="fieldvalue" field="MensClubNewMembers" enclosevalueinquotes="false" value="2"/> </updates> </action> </iftrueactions> </action> </actions> <events> <event>row.updated</event> </events> <fields> <field>RunReport</field> </fields> </action> </actions> </model> <model id="Membership_Report_Tab__MensClubNewMembersByJoinDate" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Account"> <fields> <field id="Name"/> <field id="IMIS_Account_ID__c"/> <field id="Email__c"/> <field id="Id"/> <field id="Contacts" type="childRelationship" limit="10"> <fields> <field id="Name"/> <field id="Email"/> <field id="HomePhone"/> <field id="MobilePhone"/> <field id="Phone"/> <field id="MailingState"/> <field id="MailingCountry"/> <field id="MailingCity"/> <field id="MailingStreet"/> <field id="MailingPostalCode"/> </fields> <conditions> <condition operator="in" type="multiple" field="Member_Type__c" value="" enclosevalueinquotes="true"> <values> <value>Member Primary</value> <value>Member Spouse</value> <value>Member Partner</value> <value>Non Resident Spouse</value> <value>Non Resident Primary Member</value> <value>Member Secondary</value> </values> </condition> <condition enclosevalueinquotes="true" operator="=" type="fieldvalue" field="Gender__c" value="Male"/> </conditions> </field> <field id="Board_Election_Date__c"/> </fields> <conditions> <condition type="modelmerge" value="" field="Board_Election_Date__c" operator="gte" model="Membership_Report_Tab__MensClubNewMembersVars" enclosevalueinquotes="false" mergefield="BilledSinceDate" novaluebehavior="noquery"/> </conditions> <actions/> </model> </models> <pageregioncontents> <pageregioncontent regionid="sk-37OVs0-172" uniqueid="sk-pE2-145"> <components> <tabset rememberlastusertab="true" defertabrendering="true" uniqueid="sk-11N--1845"> <tabs> <tab name="Men's Club New Members" loadlazypanels="true"> <components> <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="Membership_Report_Tab__MensClubNewMembersVars" uniqueid="sk-2sKd-2443" mode="edit" layout="above"> <columns layoutmode="fixed"> <column width="50%" uniqueid="sk-2sKd-2439"> <sections> <section title="Report Properties" uniqueid="sk-2sKd-2440" collapsible="no"> <fields> <field uniqueid="sk-2sKd-2444" id="BilledSinceDate" required="true" monthpicker="true" yearpicker="true" yearpickermin="c-10" yearpickermax="c+10" showtodaybutton="true"> <label>Billed Since Date (If they have been billed &amp; have paid MC Dues since this date and not before this date, they are considered new Men's Club Members)</label> </field> <field uniqueid="sk-2sL1-2948" type="BUTTON"> <text>Run Report</text> <renderconditions logictype="and" onhidedatabehavior="keep"/> <enableconditions logictype="and"> <condition type="blank" operator="!=" fieldmodel="Membership_Report_Tab__MensClubNewMembersVars" sourcetype="fieldvalue" field="BilledSinceDate" value="null" enclosevalueinquotes="false"/> </enableconditions> <actions> <action type="updateRow" fieldmodel="Membership_Report_Tab__MensClubNewMembersVars" affectedrows="context"> <updates> <update valuesource="fieldvalue" field="RunReport" enclosevalueinquotes="false" value="1"/> </updates> </action> </actions> </field> </fields> <renderconditions logictype="and"/> </section> </sections> </column> <column width="50%" uniqueid="sk-2sKd-2441"> <sections> <section title="Section B" uniqueid="sk-2sKd-2442" collapsible="no" showheader="false"> <fields/> </section> </sections> </column> </columns> </basicfieldeditor> <image source="staticresource" uniqueid="sk-2sMc-3587" datasource="salesforce" behavior="none" resource="LoadingWheel" resourceContentType="image/gif"> <styles> <styleitem type="itemsize" width="custom"> <styles> <styleitem property="width" value="100px"/> </styles> </styleitem> <styleitem type="border" padding="all"> <styles> <styleitem property="padding" value="20px"/> <styleitem property="box-sizing" value="border-box"/> </styles> </styleitem> <styleitem property="margin" value="0 auto"/> </styles> <renderconditions logictype="and"> <rendercondition type="fieldvalue" operator="=" enclosevalueinquotes="false" fieldmodel="Membership_Report_Tab__ModelLoaded" sourcetype="fieldvalue" nosourcerowbehavior="deactivate" field="MensClubNewMembers" value="1"/> </renderconditions> </image> <wrapper uniqueid="sk-2sMX-3554"> <components> <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Membership_Report_Tab__MensClubNewMembersByJoinDate" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-2tdb-1893" heading="By Join Date"> <fields> <field id="Name" hideable="true" uniqueid="fi-2tdo-2051"/> <field id="Board_Election_Date__c" hideable="true" uniqueid="fi-2tdo-2052"/> </fields> <rowactions> <action type="edit"/> <action type="delete"/> </rowactions> <massactions usefirstitemasdefault="true"> <action type="massupdate"/> <action type="massdelete"/> </massactions> <views> <view type="standard"/> </views> <renderconditions logictype="and"/> </skootable> </components> <styles> <styleitem type="background"/> <styleitem type="border"/> <styleitem type="size"/> </styles> <renderconditions logictype="and"> <rendercondition type="fieldvalue" operator="=" enclosevalueinquotes="false" fieldmodel="Membership_Report_Tab__ModelLoaded" sourcetype="fieldvalue" nosourcerowbehavior="deactivate" field="MensClubNewMembers" value="2"/> </renderconditions> </wrapper> </components> <renderconditions logictype="and"/> <oninitialshowactions/> <onshowactions/> </tab> </tabs> </tabset> </components> </pageregioncontent> </pageregioncontents> <components/> <resources> <labels/> <javascript/> <css/> <actionsequences uniqueid="sk-11N2-1178"/> </resources> <styles> <styleitem type="background" bgtype="none"/> </styles> </skuidpage> 


  • Mark LMark L ✭✭✭✭
    edited October 14, 2019
    Side question: How do I tell what version of SKUID I'm running? I'm using the v1 API currently. Should I be? What is the latest version of SKUID?
  • Mark LMark L ✭✭✭✭
    edited October 15, 2019
    I've created a Salesforce custom object I'm calling "SKUIDVars" that I intend to use in place of a UI only model for basic variables like Date fields that seem to have this comparison bug in UI only models. I've created a Salesforce Date field on this custom object called Date. Doing the date comparison between this actual Salesforce Date field instead of a UI only Date field fixes the query condition and now the query works properly.

    This definitely looks like some sort of a bug with comparison of Salesforce Date fields and UI Only model Date fields.
  • edited October 16, 2019
    Can you see if the condition is actually active when you query? If you're doing field in another model where the other model is UI only, the page gives you an error message on load at the top saying those fields are client-side and will be deactivated. That could be causing the problem. You may have to re-activate the condition, or set the condition to single value and use an activate & set condition action to set the condition value. Here's an example filtering for CloseDate < uiDate

    <skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
        <models>
            <model id="Oppty" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Opportunity" orderby="CloseDate DESC">
                <fields>
                    <field id="RecordTypeId"/>
                    <field id="Id"/>
                    <field id="Name"/>
                    <field id="StageName"/>
                    <field id="ForecastCategoryName"/>
                    <field id="Amount"/>
                    <field id="CloseDate"/>
                </fields>
                <conditions>
                    <condition type="fieldvalue" value="" field="CloseDate" operator="lte" mergefield="uiDate" novaluebehavior="deactivate" state="filterableoff" inactive="true" name="CloseDate" enclosevalueinquotes="false"/>
                </conditions>
                <actions/>
            </model>
            <model id="uiControl" limit="20" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true">
                <fields>
                    <field id="uiDate" displaytype="DATE" label="uiDate" ogdisplaytype="TEXT"/>
                </fields>
                <conditions/>
                <actions/>
            </model>
        </models>
        <components>
            <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="client" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="uiControl" buttonposition="" mode="edit" allowcolumnreordering="true" responsive="true" uniqueid="sk-3LBn-450">
                <fields>
                    <field id="uiDate" uniqueid="fi-3LBn-451"/>
                </fields>
                <rowactions>
                    <action type="edit"/>
                    <action type="delete"/>
                </rowactions>
                <massactions usefirstitemasdefault="true">
                    <action type="massupdate"/>
                    <action type="massdelete"/>
                </massactions>
                <views>
                    <view type="standard"/>
                </views>
            </skootable>
            <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Oppty" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-3LBo-501">
                <fields>
                    <field id="RecordTypeId" uniqueid="fi-3LBo-502"/>
                    <field id="Id" uniqueid="fi-3LBo-503"/>
                    <field id="Name" uniqueid="fi-3LBo-504"/>
                    <field id="StageName" uniqueid="fi-3LBo-505"/>
                    <field id="ForecastCategoryName" uniqueid="fi-3LBo-506"/>
                    <field id="Amount" uniqueid="fi-3LBo-507"/>
                    <field id="CloseDate" uniqueid="fi-3LBo-508"/>
                </fields>
                <rowactions>
                    <action type="edit"/>
                    <action type="delete"/>
                </rowactions>
                <massactions usefirstitemasdefault="true">
                    <action type="massupdate"/>
                    <action type="massdelete"/>
                </massactions>
                <views>
                    <view type="standard"/>
                </views>
                <actions defaultlabel="Global Actions" defaulticon="sk-icon-magic" usefirstitemasdefault="true">
                    <action type="multi" label="Query" icon="sk-icon-refresh">
                        <actions>
                            <action type="blockUI" message="{{$Model.uiControl.data.0.uiDate}}" timeout="1000"/>
                            <action type="setCondition" model="Oppty" condition="CloseDate" value="{{$Model.uiControl.data.0.uiDate}}"/>
                            <action type="requeryModel" model="Oppty" behavior="standard"/>
                        </actions>
                    </action>
                </actions>
            </skootable>
        </components>
        <resources>
            <labels/>
            <javascript/>
            <css/>
            <actionsequences uniqueid="sk-2pmT-224"/>
        </resources>
        <styles>
            <styleitem type="background" bgtype="none"/>
        </styles>
    </skuidpage>

  • Mark LMark L ✭✭✭✭
    edited October 16, 2019
    How are you able to investigate/tell if the condition is actually active when querying live?

    "If you're doing field in another model where the other model is UI only, the page gives you an error message on load at the top saying those fields are client-side and will be deactivated."

    Why does this happen? That seems problematic.
  • edited October 16, 2019
    This happens because Skuid queries SFDC first on page load, so the UI-Only models and fields don't exist at this point. Since it doesn't exist, Skuid deactivates the conditions dependent on the information.

    To see if it's active or not, the easiest way is to dive into the model map. In console. type skuid.model.map() and you'll get a list of models on the page. You can click into the models for details associated with that model (data, conditions, fields, errors, what the last soql query was, etc). If you know the specific model, you can also access this information if you type skuid.$M('modelname'), but I generally prefer the model map personally. Here's more info on that - https://docs.skuid.com/latest/en/skuid/debug/
  • Mark LMark L ✭✭✭✭
    edited October 16, 2019
    Thanks for the debugging info. I took a look and the model condition is set to inactive on the live page.

    Why does squid query SFDC first on page load and deactivate conditions referring to UI only models? Can you explain that more? I'm using process client side for all my models and I'm not querying anything on page load, why would SKUID need to mess with the model conditions in this way?

    If the system didn't mess with the conditions in this way, the query would work properly, correct? How can I make SKUID not mess with conditions or work around this process? Is creating an actual Salesforce custom object to use in a model instead of a UI only model my best solution, or is there some way via Javascript I can force the conditions it inactivated to reactivate (and how do I know which ones it deactivated)? If I have UI only fields on a Salesforce object model, will this happen with those fields as well?

    It's not a clearly apparent thing that SKUID is doing here, it's really unexpected/surprising behavior causing bad query data without a clear indication that it's happening unless you really look at the debugger and see what's going on. I don't understand why it is set up to work this way. If the models all process client side and don't query on page load, why would SKUID go through and deactivate their conditions permanently?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!