These docs are for v3.2. Click to read the latest docs for v5.0.

Discussions

Ask a Question
Back to All

Clarity on fetching data from other OC Modules

(edited)

I have a hidden page called Management and have an OC module (multi items) with a list of client names with some basic attributes. My data looks something like this.

[
{
    "name": "Jane Smith",
    "gender": "female"
  },
  {
    "name": "Joe Someone",
    "gender": "male"
  },
  {
    "name": "Bob Jones",
    "gender": "male"
  }
]

On another page named Clients I have another OC module with a template that display a bootstrap profile card type layout. In my form builder I have two fields.

  1. Client Name (Select2)
  2. Position (Text)

I understand that you must manually edit the options.json file to configure the Select2 properties so they point to the OC module in the Management page. I have something list this.

{
  "fields": {
    "clientName": {
      "type": "select2",
      "dataService": {
        "action": "Lookup",
        "data": {
          "moduleId": "692",
          "tabId": "173",
          "valuefield": "name",
          "textfield": "Name"
        }
      }
    },
    "positionTitle": {
      "type": "text"
    }
  }
}

and my template.hbs file looks something like this.

<ul>
  {{#each Items}}
    <li class="gender-{{clientName.gender}}">{{clientName}} - {{positionTitle}}</li>
  {{/each}}
</ul>

My question is, how can I grab the gender value as well so my html output looks something like

<ul>
  <li class="gender-female">Jane Smith  - CEO</li>
  <li class="gender-male">Joe Someone - Accounts</li>
  <li class="gender-male">Bob Jones - Marketing</li>
</ul>

I have tried grouping the clients list into objects like below but still no go.

[
  {
    "client": {
      "name": "Jane Smith",
      "gender": "female"
    }
  },
  {
    "client": {
      "name": "Joe Someon",
      "gender": "male"
    }
  },
  {
    "client": {
      "name": "Bob Jones",
      "gender": "male"
    }
  }
]

If anyone can point out what I'm doing wrong your help would greatly be appreciated.