Invalid Reference Id error on dependent model 'create row if none found'

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
I have two models, Feedback and FeedbackSignature. Both are set up to pull one record, load on pageload, and create row if none found.

FeedbackSignature has a lookup reference to Feedback, and it is populating correctly with the skuid temp id on pageload.

However, components on the FeedbackSignature model are giving an "Invalid Reference Id: Feedback" error (even though I haven't attempted to save anything).

Once I've saved Feedback, I no longer get the error.

Why this error?

Ideally, I'd like to be able to save FeedbackSignature before saving Feedback, but that might be asking too much... 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Any help on this would be greatly appreciated!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
I set up a model action on Feedback to save itself (and to save itself and FeedbackSignature) when a new row was created, but to no avail. Still getting the error.

This seems odd:

In the FeedbackSignature model, why would Feedback__r.Id have the right ID, but Feedback__c still have "1"?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Looks like I was able to solve with a model action initiated by a new row on Feedback set to save both Feedback and FeedbackSignature in the same action. Interestingly, it's still not actually saving FeedbackSignature to the database (the model still has a temporary id), but it's not giving me the error anymore, so that's happy. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
So.. Glad you figure this out. And sorry this slipped through the cracks. 

You will not be able to save the Signature before saving the Feedback because of the temporary ID.  Trying to save that temp ID to the database will give you an error.  You will have to save Feedback,  which will replace its temp ID with a real one, and pass that along to any models that are using that temp ID.  All this will happen correctly in a single "MultiModel save" but you have to keep your model order right, and you can't try to do circular references (where A refers to B and B refers to A) cuz we can't work out the mutual dependencies.  One has to be the winner. 

Hope that all helps.