How do you prepopulate a reference field?

I am working on a form that creates a new salesforce opportunity. One field on the page is a lookup to Contact records. I want to prefill this field while doing testing. I have a button created that has an Update Rows action on it that I use to prefill several pieces of data. This button is able to prefill everything except this lookup field. I can’t figure out what value I need to set to get this to work. I’ve tried using Id but nothing shows up in the lookup field on the form, nor does a value appear when I display a table of the data in the model I am trying to prepopulate. Does someone know what the correct syntax / declarative settings are that I need to get this to work?

If you’re using merge syntax, try using 3 curly brackets around the merge syntax, e.g. {{{Id}}}

3 return the raw value, while 2 might try to return something understandable. E.g. {{Id}} would return the Name of the record.

So I tried something like this:


but I still don’t see the Contact selected in the lookup. I just see this:


I suspect if you press your button, save the model, then refresh the page the expected value will show up. I think the Id is being stored in the model but it is not updating the reference information.

I don’t know if this is appropriate… If you update the Id field as you do above, as well as, if update the name field similarly {{{$}}} will show you what you expect to see.

Nonetheless I don’t know why this is happening, so I’m unable to help more.

(Recording this for posterity.)

Ok, I figured it out. Turns out to be pretty simple. I wasn’t bringing in the fields I use in the Display template for the Deal Contact to the model that I use to grab the ID of the placeholder Contact I want to use. So it the Deal Contact field WAS getting the ID value, but it didn’t have the pieces it needed to display the information and thus was showing only the two hyphens that I use to format what users see in the dropdown after they select a result. (See first screenshot along with this new one).


1 Like

Glad you figured it out.
Just because you move the ID into the record - doesn’t mean that SKuid knows the related “Name” data (or other data you want to show off). You need to bring those fields accross with your action as well.