Row (model.data) properties for non-cloned row different than cloned row

  • 1
  • Question
  • Updated 4 years ago
Fairly certain that this is not by design and an unintended side-effect but marking it as a question for now...

When a row is retrieved on page load, it contains the fields defined on the model for that page.

If the row was cloned, two items of note on the resulting data.row
1) The row contains relationship fields as fully qualified properties on the root row object (e.g. data.row[0]['CustomField__r.Name'] and data.row[0]['CustomField__r']['Name'])
2) After a search of that field via a Field editor, the fully qualified version of the field is not updated so the fully qualified relationship property (data.row[0]['CustomField__r.Name']) does not equal the relationship object property (data.row[0].['CustomField__r']['Name']).  Fortunately, since the "__r" field always appears to get added to the row object first, when accessing data.row[0].CustomField__r.Name you end up with the correct value even though there are two property keys that match.

Understanding that the recommended approach to access data is via getFieldValue which protects against inadvertently accessing the fully qualified property, the result of this raises two concerns assuming this is not by design:

1) Potentially retrieving incorrect data if a method other than getFieldValue is used
2) Increased memory utilization and decreased performance (time spent copying unnecessary data)

For example - Assuming CreatedBy & OwnerId were selected on Model
Non-Cloned Row (account.data[0]) has:
CreatedBy : { Id: "555555555555555555", Name: "john" }
CreatedById : "555555555555555555"
Owner: { Id: "444444444444444444", Name: "steve" }
OwnerId: "444444444444444444"

Cloned Row (account.data[0]) has:
CreatedBy : { Id: "555555555555555555", Name: "john" }
CreatedBy.Name: "john"
CreatedById : "555555555555555555"
Owner: { Id: "444444444444444444", Name: "steve" }
Owner.Name: "steve"
OwnerId: "444444444444444444"

After a search for Owner and selecting a different one on the cloned row:
CreatedBy : { Id: "555555555555555555", Name: "john" }
CreatedBy.Name: "john"
CreatedById : "555555555555555555"
Owner: { Id: "444444444444444444", Name: "joe" }
Owner.Name: "steve"
OwnerId: "444444444444444444"

Steps to Reproduce:
1) Create page using XML below
2) Preview page specifying any account
3) Inspect the following in console
- skuid.model('Account').getFirstRow()
4) Change the value for Owner
5) Inspect the following in console
- skuid.model('Account').getFirstRow()

Everything works as expected thus far

6) Add a &clone=1 to the URL on the preview page and reload page
7) Inspect the following in console
- skuid.model('Account').getFirstRow()
- Note that the row has fully qualified CreatedBy.Name and Owner.Name properties on row object
8) Change the value for Owner
9) Inspect the following in console
- skuid.model('Account').getFirstRow()
- Note that the row has fully qualified CreatedBy.Name and Owner.Name properties on row object
- Note that the value of row['Owner']['Name'] does not equal row['Owner.Name']

Sample Page
<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true" tabtooverride="Account">   <models>
      <model id="Account" limit="1" query="true" createrowifnonefound="false" sobject="Account" doclone="" type="">
         <fields>
            <field id="Name"/>
            <field id="CreatedById"/>
            <field id="CreatedBy.Name"/>
            <field id="OwnerId"/>
            <field id="Owner.Name"/>
         </fields>
         <conditions>
            <condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <basicfieldeditor showsavecancel="false" showheader="true" model="Account" mode="read">
         <columns>
            <column width="100%">
               <sections>
                  <section title="Basics" collapsible="no">
                     <fields>
                        <field id="Name"/>
                        <field id="OwnerId" valuehalign="" type="" optionsource="">
                           <searchfields/>
                        </field>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
</skuidpage>
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You are the documentation king!!!
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
lol, thanks Pat...gotta get my daily typing practice in :)