New row created with different values on "__c" and "__r.Id" fields of a reference field

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
When a row is created in a component that has context, the "__c" field value is different than the "__r" field that is being established.  This is due to the target model having a filterable condition and based on the condition value that was last established.  That said, since the "__c" field value is correct and the component has context, the "__r" should match the "__c".  

Notes
1) This might be the same as https://community.skuidify.com/skuid/topics/-r-field-of-condition-field-not-being-set-when-creating-... but since it presents differently, I'm logging it separately
2) If you repeat the same steps but choosing an account with Contacts for Step #3, the problem does not seem to occur.

Steps to reproduce:
1) Create page using XML below
2) Preview page
3) Expand row for an account that does NOT contain contacts
4) Click "Add New"
5) Inspect skuid.$M('Contact').data[0]

Expected Behavior
AccountId equals Account.Id

Actual Behavior
AccountId is correct but Account.* does not exist (see https://community.skuidify.com/skuid/topics/-r-field-of-condition-field-not-being-set-when-creating-...)

6) Expand a row that does contain contacts
7) Click "Add New"
8) Inspect skuid.$M('Contact').data[0]

Expected Behavior = Actual Behavior
AccountId is equal to Account.Id

9) Click "Add New" from the drawer that was expanded in Step #3

Expected Behavior
AccountId = Account.Id

Actual Behavior
AccountId is correct, but Account.* is from the account that was expanded in Step #6

Sample XML
<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true" tabtooverride="Account" personalizationmode="server">   <models>
      <model id="Account" limit="" query="true" createrowifnonefound="false" sobject="Account" type="" adapter="" doclone="" processonclient="true">
         <fields>
            <field id="Name"/>
            <field id="Id"/>
            <field id="CreatedById"/>
            <field id="CreatedBy.Name"/>
            <field id="CreatedDate"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
      <model id="Contact" limit="" query="false" createrowifnonefound="false" adapter="" type="" sobject="Contact" doclone="" processonclient="true">
         <fields>
            <field id="FirstName"/>
            <field id="Name"/>
            <field id="LastName"/>
            <field id="AccountId"/>
            <field id="Account.Name"/>
            <field id="Account.CreatedById"/>
            <field id="Account.CreatedBy.Name"/>
            <field id="Account.CreatedDate"/>
         </fields>
         <conditions>
            <condition type="fieldvalue" value="" field="AccountId" operator="=" mergefield="Id" novaluebehavior="noquery" state="filterableoff" inactive="true" enclosevalueinquotes="true" name="AccountId"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="10" createrecords="true" model="Account" buttonposition="" mode="read" uniqueid="sk-2Pc4hF-116" emptysearchbehavior="query">
         <fields>
            <field id="Name"/>
         </fields>
         <rowactions>
            <action type="multi" label="View Details" icon="sk-icon-magic">
               <renderconditions logictype="and"/>
               <actions>
                  <action type="drawer">
                     <drawer title="Drawer Area" width="90%" closehandle="true">
                        <components>
                           <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="10" createrecords="true" model="Contact" buttonposition="" mode="edit" uniqueid="sk-vf_Az-142" emptysearchbehavior="query">
                              <fields>
                                 <field id="FirstName"/>
                                 <field id="LastName"/>
                              </fields>
                              <rowactions>
                                 <action type="edit"/>
                                 <action type="delete"/>
                              </rowactions>
                              <massactions usefirstitemasdefault="true">
                                 <action type="massupdate"/>
                                 <action type="massdelete"/>
                              </massactions>
                              <views>
                                 <view type="standard"/>
                              </views>
                              <conditions>
                                 <condition type="contextrow" field="AccountId" mergefield="Id" operator="="/>
                              </conditions>
                              <actions defaultlabel="Global Actions" defaulticon="sk-icon-magic" usefirstitemasdefault="true">
                                 <action type="multi" label="Add New" icon="sk-icon-magic">
                                    <actions>
                                       <action type="createRow" model="Contact" appendorprepend="prepend" defaultmodefornewitems="edit"/>
                                    </actions>
                                 </action>
                              </actions>
                              <searchfields/>
                           </skootable>
                        </components>
                        <beforeload>
                           <action type="setCondition" model="Contact" condition="AccountId" value="{{Id}}"/>
                           <action type="requeryModels" behavior="loadmore">
                              <models>
                                 <model>Contact</model>
                              </models>
                           </action>
                        </beforeload>
                     </drawer>
                  </action>
               </actions>
            </action>
         </rowactions>
         <massactions usefirstitemasdefault="true"/>
         <views>
            <view type="standard"/>
         </views>
         <searchfields/>
      </skootable>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks Barry - we are looking into this. 
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Thanks Rob!
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
This appears to have been addressed in Update 8 (7.36) - likely related to the fix for SKUID-2017.

Skuid Team - Can you confirm if this is resolved?
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Yes, the fix for SKUID-2017 should fix this issue as well. In case you're interested, client side models were not correctly registering themselves into a ModelsByKeyPrefix cache. Then, when our create row functionality looked for other models to glean data from for reference data, it was not finding it. 
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Thanks for confirming Ben and yes, always interested in and appreciate the details :)