fill in lookup value in updateRow

I’m updating a row in javascript.
Some of the values are lookup values. For example, I use a custom object to hold a list of hours.
So when I’m doing the update I know the hour number ( maybe 3 ), but I need to supply the id of the custom hour objects row that has 3 as its name.
I was setting up some models to use to get the id (by filtering them to get them to hold the right row and reading the value from that) when I wondered if there wasn’t some way to just pass the value “3” to updateRow and have the field determine the Id of the hour object to insert.

I’m afraid that our API is not able to automatically lookup an Id based on a name. It sounds like you are taking the most appropriate approach at the moment.

In the few places where we enable similar functionality (such as reference fields), we are basically doing the same thing you are doing - creating a Model on the fly with a condition allowing the code to look up records by a given name (or other field) and applying the Id of the record selected by the user.

It would be nice to have an API feature capable of doing all this work for you… we’ll certainly consider it going forward as the need for this sort of task does come up every now and again.

JD, you say “creating a model on the fly”, can you create a model in javascript ?

Yes, but in the same sense that we build Models “on the fly” based on the page’s XML. There’s no public API available to do this and it’s not a simple process. What you are doing is significantly easier and is definitely the recommended path.

We are forced to take a much more difficult approach because we cannot always guarantee that the models needed to support reference fields will exist on the user’s page (even if they did, we would not want to mess with those models conditions and cause unexpected behavior).

When we are building our own pages, we generally follow the same path you have taken - define a Model with the needed conditions declaratively, then set conditions from JS.

About creating models in JavaScript, if only there was a helpful tutorial … http://help.skuidify.com/m/11720/l/228794

Thanks Moshe… didn’t realize that we had posted such a detailed tutorial on creating Models dynamically!

It’s still a rather complicated process, as you can see, and is best reserved for edge case scenarios. It’s much easier to create and maintain models declaratively from the page composer.