Is it possible to read the Multi-relational field selection and loop each item from Javascript

I have a multi-relational field on my form. I would like to loop through the values and retrieve the ts_id and some custom fields from the aux table that the relational field is pointing to within a javascript.

Is it possible read the field as an array and is it possible to catch the record id?

  • Yes, if you're on one of the newer versions of SBM you should have an "ivalue" attribute available for the field which contains a comma-separated list of the selected values. Retrieving additional data from an Aux table will require the use of Javascript to make a server request (using either a report JSON template or a custom API) and obtain the desired values using the ID's which you have available.
  • Thanks Jeff, I saw the ivalue on the form but I was not able to retrieve it. Do you have an example?
  • The simplest way (without writing your own API) would be to create a Listing report with a Query-at-runtime value, save it with a Reference Name, and then use the JSONlist template to query that report and process the results.

    Here is a simple example using jQuery.getJSON (you'll need to put in your own variables):

    "template": "reports/jsonlist",
    "HasRuntimeParams": 1,
    "F_SOME_SEARCH_VARIABLE": mySearchVariable,
    "RECNO": -1 // Return all results without pagination

    }, function(data){
    if (data
  • Thank you Jeff, I think I understand what you are doing but I can't find a context to run it in. Is it possible to embed in a form and manipulate from there?
  • Yes, I would put it into an "Execute Javascript" within a Form Action. If the data is available at the time the page is loaded, you can use "When page is loaded", otherwise use "When a field changes" to trigger. I didn't go into detail about how to get the actual field id values - you can do that with a function such as this:

    $("span", GetFieldWidgetByName("MY_MULTIRELATIONAL")).each(function(){
    // Do something with each value
  • Hello again Jeff,

    I really like the look of this, if I understand it correctly. I would like to read the aux table as a json list and be able to use the data as I wish.
    BUT, doing this I still don't get it to return the data. Is there any way you can help me, perhaps online?