Skip to main content

When pulling in data via an OData service, only the first row of data is displayed in a table even though the model contains all expected rows.


I’ve narrowed this down to only seem to occur when an “Id” equivalent type of field is not included in the model.


For example, using the OData test service at (http://services.odata.org/V3/OData/OData.svc/) with ODataDemo.Categories, if the model contains “Name” only, the table only displays the first row. However, if the model also includes “Id”, all model data is displayed in the table. In either situation however, the model itself contains all rows as you can see in the screenshot below with the footer indicating 1-3 of 3 rows.


Not sure if this is expected behavior (if so, a doc updated might be appropriate) or a defect?


Screen Capture


Steps to repro:


  1. create necessary OData setup for http://services.odata.org/V3/OData/OData.svc/

  2. Add model to page choosing the service and specifying Name field only

  3. Add model to page choosing the service and specifying Name & Id

  4. Add table to page choosing model from #2 and Name only

  5. Add table to page choosing model from #3 and Name only

  6. preview page

Expected Result

Both tables contain 3 rows


Actual Result

Table from #4 displays 1 row, table from #5 displays 3 rows


Sample Page XML


<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">   <models>
<model id="Category" limit="20" query="true" createrowifnonefound="false" adapter="OData1-3" processonclient="true" service="ODataTestServiceRO" sobject="ODataDemo.Categories" label="Category" labelplural="Categories">
<fields>
<field id="Name"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="CategoryWithId" limit="20" query="true" createrowifnonefound="false" adapter="OData1-3" processonclient="true" service="ODataTestServiceRO" sobject="ODataDemo.Categories" label="CategoryWithId" labelplural="CategoriesWithId">
<fields>
<field id="ID"/>
<field id="Name"/>
</fields>
<conditions/>
<actions/>
</model>
</models>
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Category" buttonposition="" mode="read" uniqueid="sk-2B_zUx-143">
<fields>
<field id="Name"/>
</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" pagesize="10" createrecords="true" model="CategoryWithId" buttonposition="" mode="read" uniqueid="sk-2B-SfE-215">
<fields>
<field id="Name"/>
</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>

Thanks!

One additional note - If you edit the Name field in table from #4, the "Save" button does not enable.  Editing the name field in table from #5 and it does.  Seems as though some type of unique id is required in model which would make sense (doc update??) for edit but unclear on why data wouldn't display initially when its in the model (no error messages in console btw).  Thanks!


I was just going to write this up - To reinforce what Barry is saying, when I bring in data exposed via Lightning Connect, the table displays all rows, as expected. When I connect to the same data source directly via OData, the table shows that the right number of rows are there, but only the first row is displayed.



Do these odata sources have some kind of primary keys specified in their metadata? If so, can you try adding those fields to the model and see if they display correctly? This is usually an “Id” field of sorts.


Hi Ben - See the comments in my OP and my follow-on reply.  If the “Id” field is included in the Skuid model, everything works as expected.  However, if this field is not included in the Skuid model, that’s when the issues described are encountered.  A few thoughts/comments:

1) Not sure why including a PK would be necessary to display data in a table.  Allowing “edit” I would understand but unclear on why for view its required.
2) When using an OData source that supports Read-write, if a PK is not included, a javascript error is encountered after clicking “Save”
3) If a PK is required for OData support in Skuid, possibly one (or more) of the following?
- Mention this in the docs so users know to always include a PK
- Use the $metadata and automatically include this field by default when creating the model.  
- Possibly even make the “Id” field disabled so users can’t remove it from the model
- At the very least, display a message if it’s ever disabled indicating that its required for full support

Thanks!


Same with me - including the PK field and everything worked as desired. And per Barry’s comments - what if you were to somehow flag it while in design mode? Some visual cue that this will not work without the inclusion of the PK? 


Hey, guys. Short story, we’re tagging this as a bug, to be fixed soon. For Salesforce models, we automatically include the Id field at runtime even if you don’t select it at buildtime. Since you can have compound keys in OData, we are reading from the metadata and constructing an “Id” field for each row. However, we aren’t adding the fields to the model at runtime if you don’t select them, which means the constructed Ids aren’t correct, and some of our components react unexpectedly (like you saw with Table).

As always, thanks so much for the feedback and for putting this release through its paces!


Sounds great J, thank you!


Hi J/Ben - Thought of a couple of follow-up questions based on J’s last comment.

1) What will happen if there is no “Key” for a given Entity?  Will this be a supported scenario at least for “read”?

2) What will happen if there is a key but the $metadata doesn’t describe it?  Will there be a way via the page designer/builder UI to specify a field as a key or a combination of keys as a compound key?

Thanks!


While we’re certainly willing to entertain exceptions, we are trying to adhere to the OData 3 spec as closely as possible. Per the spec, an Entity Type must have a key or a Base Type from which the key can be inherited. At least with the initial release (and likely for the time being after that), if your metadata isn’t publishing according to this guideline, we won’t provide a way at buildtime to account for it.

Good news though: the patch for auto including Key fields is ready to go and will be included in the next release (7.6)!


Thanks J, adhering to the spec makes perfect sense.  I had checked the OData schema before posting my question last night and noticed minOccurs=0 but neglected to look at the spec and the part you pointed out.  Sorry about that!

Along these lines, if no key is found, will skuid display an error after specifying the external object name?

Great news on the patch, thanks for the quick turnaround!



Reply