Accessing Custom Type's Values in Javascript

Hey you plugin gurus…

I have a quite basic javascript experience, and am looking to use that in creating some javascript code for my app. A couple of questions arise as I progress…

I have a field for an Element Action which is of a custom type “Event”…

(1) How do I access fields of that type such as “Event Name”?

(2) My Event type has a field which is of custom type “Location”. How do I access a field such as “Event’s Location’s Title”?

And finally…

(3) Am I right in saying that if I want to produce some output from an Action, I have to use an Element Action? Is it true that an Action (either client or server side) cannot produce any output that I can use in a subsequent action?

(4) Is there some detailed documentation about all this that I am missing? I can’t find any details in the manual or reference. I’ve just followed @copilot 's immensely useful video tutorial series.

Thanks in advance!

Hey @antony,

Thanks for the kind words! To share some guidance here from what we’ve seen (in order):

  1. With use of ‘Any thing’ (meaning any Thing a Bubble user may have in their application) as a Field’s type, you’ll make to make use of Bubble’s provided functions to extract that Thing’s Fields. An example case may be obj.getProperties() which equates to “Return an array with obj’s fields from and including the first to and including the last.”.

  2. You’ll have to setup an evaluator within JavaScript, which could look something like obj.subObj.title. To use what Bubble provides, it may look something like subObj.get("Title"). Put simply, use Bubble’s provided get() function to get the value of a field. Definitely look at nested data guides to learn more about object structures work.

  3. If you set an Action to be server-side, you’ll be able to configure your Returned Values.

  4. Just like other libraries, tools and environments, you may be given tools and guides to get you started but most of the work comes from your own creativity in problem-solving.

There are plenty of talented developers in our community that could assist you further. We’re looking to update our Plugin Development course to address new features and best practices pretty soon. :slight_smile:

1 Like

Hey, @copilot, thanks for the detailed response! I will go away and have a play…
Your support is much appreciated! :slight_smile:

@copilot, thanks for your help so far! So here is where I have got to with a server side action…

  • I can access a simple text input field okay.
  • I can write to a returned value okay.
  • But I can’t access an input which is of type “any thing” or “any thing with fields”, it has a null and undefined value in the Javascript.

Is there anything obvious I have set up wrongly from what is shown below?

Thanks in anticipation!
Antony. :slight_smile:


Yeay, I am so happy, I have solved it - click here for all the details! :slight_smile: