Access field metadata in builder?

  • 1
  • Question
  • Updated 1 year ago
  • Answered
Another custom component question. :)

I have a model property on a custom component.

I'd like to create a picklist property where the picklistEntries are defined by the metadata for a picklist field in the specified model.

Even better, I could dynamically create a model on the desired sObject and get the picklistEntries from a field that way.

I've tried both, without success.

It seems like skuid.$M() returns undefined even when the model 'exists'... I suspect that a model has to be loaded for that to work?  What if I create a model new model with skuid.model.Model() in the builders.js and call .initialize().load()?

Here's my real question: Is there a way to access field metatdata on the builder-side in order to dynamically define picklist entries for a component property?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
It Works!

I created a model with new skuid.model.Model(), and then used .initialize().register().load().

Not sure if I need all three of those... but it's working. :)

If there's a better way to accomplish this, I'd love to know.

Thanks!
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Creating a fake Model would work. Right now the Skuid Composer doesn't always load picklist entries for all fields --- to conserve memory, since this can be a TON of Picklist Entries for some folks' Picklist fields --- so there's not a function I can point you to, unfortunately.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Zack, et al.,

What does the getMetadataForField() function do in skuid.builder.core?
Would that address the need to access a field's picklist entries on the builder side?
(Edited)