UI Only Picklist Field with Picklist Source set to Rows in Model not refreshing after page load

  • 1
  • Question
  • Updated 2 years ago
  • Answered
How do I refresh the values in a UI only picklist field that has a picklist source of "Rows in Model"?

Assume
  • Model A contains the UI only Picklist Field
  • Model B is the source of the picklist in Model A. Model B is also filtered by a Lookup value in Model A.
Attempt:
  • Set value for Model A lookup filed (which is a filter value for Model B)
  • Save Model A
  • Query Model A (just in case the model does not reflect the latest lookup field just recently saved)
    *Probably unneccessary but currently doing this
  • Query Model B (So that B can reload its values based on the new filter criteria that has recently changed in Model A
  • Query Model A (So that Model A can reload itself this time repopulating the UI only field based on the newest values found in Model B)
Does the sequence of the attempt look correct or am I missing an important piece or proper sequence order when working with UI picklist fields populated from "Rows in Model"? 
Photo of Joseph Ucuzoglu

Joseph Ucuzoglu

  • 1,074 Points 1k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Janick

Janick

  • 916 Points 500 badge 2x thumb
Joseph,

From your request I think that you're trying to fill a picklist to filter, right?

In that case i think it would be better to use the built in filter functionality, either on the table or since Brooklyn, as an own component.
Otherwise your attempt looks right to me. I've used the "Filter Set" and created an action on ModelB which queries the ModelA when a new Row is created or being saved.

Here's the example i've built:


<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">
    <models>
        <model id="ModelA_Picklist" limit="20" query="true" createrowifnonefound="false" type="" sobject="CountryCodes__c" datasource="salesforce">
            <fields>
                <field id="Country_Code__c"/>
                <field id="Name"/>
                <field id="CountryCodes" uionly="true" displaytype="PICKLIST" label="Country Codes" defaultValue="Empty" picklistsource="rowsinmodel" defaultvaluetype="fieldvalue" picklistmodel="ModelA_Picklist">
                    <picklistentries>
                        <entry value="{{$Model.userwithCountryCode.data.0.Name}}" label="{{{$Model.userwithCountryCode.data.0.Name}}}"/>
                        <entry value="New Entry" label="New Entry"/>
                        <entry value="New Entry" label="New Entry"/>
                    </picklistentries>
                </field>
            </fields>
            <conditions>
                <condition type="fieldvalue" field="CountryCodes" operator="=" inactive="true" enclosevalueinquotes="true" name="__autofilter__CountryCodes" state="filterableoff" value=""/>
            </conditions>
            <actions/>
        </model>
        <model id="ModelB_CountryCode" limit="20" query="true" createrowifnonefound="false" type="" sobject="User_withCountryCode__c" datasource="salesforce">
            <fields>
                <field id="username__c"/>
                <field id="Name"/>
            </fields>
            <conditions/>
            <actions>
                <action>
                    <actions>
                        <action type="requeryModel" model="ModelA_Picklist" behavior="standard"/>
                    </actions>
                    <events>
                        <event>models.saved</event>
                        <event>row.created</event>
                    </events>
                </action>
            </actions>
        </model>
    </models>
    <components>
        <filterset model="ModelA_Picklist" searchmethod="server" searchbox="true" uniqueid="sk-2y5b7w-113">
            <filters>
                <filter type="select" filteroffoptionlabel="New Filter" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="manual" conditionfield="CountryCodes" labelmode="no">
                    <sources>
                        <source type="model" effectsbehavior="justdefault" model="ModelB_CountryCode">
                            <labeltemplate>{{{Name}}}</labeltemplate>
                            <valuetemplate>{{Id}}</valuetemplate>
                        </source>
                    </sources>
                </filter>
            </filters>
            <searchfields/>
            <renderconditions logictype="and"/>
        </filterset>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="ModelA_Picklist" buttonposition="" mode="read" uniqueid="sk-2xO4PI-93">
            <fields>
                <field id="Country_Code__c" valuehalign="" type="" uniqueid="fi-2y9hY1-234"/>
                <field id="CountryCodes" valuehalign="" type="" uniqueid="fi-2y9hY2-235"/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
            <filters>
                <filter type="select" filteroffoptionlabel="New Filter" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="manual" labelmode="no">
                    <sources>
                        <source type="manual" effectsbehavior="justdefault"/>
                    </sources>
                </filter>
            </filters>
        </skootable>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="ModelB_CountryCode" buttonposition="" mode="read" uniqueid="sk-2xOEMB-118">
            <fields>
                <field id="username__c" uniqueid="fi-2y6fNv-150"/>
                <field id="Name" valuehalign="" type="" uniqueid="fi-2y6fNv-151"/>
            </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>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>

I hope this helps

Janick