"Invalid Reference Id" error when creating records in a child table

  • 3
  • Problem
  • Updated 5 years ago
  • Solved
I have a page containing a "parent" model called "Workshop" and a table beneath it where users can create rows for "Workshop Attendance". When users click the green plus icon in the table, it fills in the parent record automatically in the lookup field (Excellent!). However, when I do so and save the page, it throws the error "Invalid Reference Id: Workshop" and no child records in the table are saved. What am I'm missing?
Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb

Posted 5 years ago

  • 3
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Official Response
Peter,

Can you try reordering these two Conditions in your Workshop Attendance model:



<conditions logic="1 OR 2">
<condition type="modelmerge" value="" field="Workshop__c" operator="=" model="Workshop" enclosevalueinquotes="true" mergefield="Id"/>
<condition type="blank" value="null" field="Workshop__c" operator="=" enclosevalueinquotes="false"/>
</conditions>


You should be able to reorder just by dragging in the Builder.

We think that the issue here is that, when new your users click to create a new Workshop Attendance record, Skuid is (helpfully) using the Conditions in your Model to pre-populate the new records' "Workshop__c" field with the corresponding Workshop's Id. But, because you have OR logic here, and because of the order of the Conditions, Skuid is first using the Model Merge condition, then it is overwriting the value with null. So, switching the order of your conditions should change this!

We'll see if there's some way we can make this not happen in a future version of Skuid.