Morpheus REST option list with dependent field

Hi Team,

I am looking to use a REST type option list with a dependent field that is passed as a parameter to the API call. However, I am running into issues getting the dependent input value passed correctly to the API. I have confirmed the API endpoint works as an option list with hard-coded parameter values to rule out any issues with the API call itself.

Appliance details

  • License: Community edition
  • Version: 6.1.1

Option List details

  • Type: REST

  • Method: GET

  • Translation script:

    for(var x=0;x < data.key.length; x++) {
      results.push({name: data.key[x].name,value:data.key[x].id});
  • Request script (not working):

    if (input.Input1 && input.Input2) {
      results=[{name:"Input1",value: input.Input1}, {name:"Input2",value: input.Input2}]
  • Request Script (with hard-coded values, working):

    results=[{name:"Input1",value: "value1"}, {name:"Input2",value: "value2"}]

Input dependencies

  • Input1: no dependent fields
  • Input2: depends on Input1
  • Input using option list: dependes on Input2

Current behavior
Option list returns empty list every time and does not update based on values entered for Input1, Input2

Is this use case currently supported in Morpheus Data? Is my option list configured correctly?

An alternative approach, which can be simpler, is to request everything in the REST call and filter in the translation script using the value of the dependent input.

Say for example this the dependent value input.myRegionID, and my option list makes a call for sites data, which returns a JSON array with objects which contain id, name and regionID key/values. The translation script below can filter the results displayed in your sites input:

results = []
for(let i=0;i<data.length;i++){
  if (input.myRegionID == data[i].regionID) {
    // add to results
    results.push({name: data[i].name, value:data[i].id})

Hi @kate_w,

I hope your week is going well!

To add to what @Ollie_Phillips mentioned, this should be possible to accomplish. I’ve created a mock similar to what you are doing. I have two select list inputs, one with a set of IDs in it using a manual Option List and another that is a REST Option List, that uses the values from the previous input.

I used this site for testing the example:

Example of the GET endpoints I’m using with parameters on their site:

In the first select list with a field name of postid, it contains ID numbers that we’ll want to choose to select the emails that are related to the postId in the returned results. The next select list with a field name of emails just lists the results from a GET REST call and shows only the email that is associated with the postId I supplied.

Note that in the Input 2 (emails), there is a dependent field set as well, this ensures that when the postid field is changed, the emails field reloads the data.

Here is some screenshots and examples from what I have.

Input 1 (postid):

Option List 1 for Input 1:

Input 2 (emails):

Option List 2 for Input 2:

Translation Script from Options List 2:

for(var x=0;x < data.length; x++) {
  results.push({name: data[x].email,value:data[x].id});

Request Scrtipt from Option List 2:

    results=[{name:"postId",value:input.postid }]

I added the Inputs to a Catalog Item for testing, here are example results:
Choosing ID 1:

Choosing ID 2:

Choosing ID 3:

Hope that helps!

1 Like

Would also work with below request script

if (input.SiteID && input.SerialID ) {
  results.push({name:"site_id",value: input.SiteID})
  results.push({name:"serial_id",value: input.SerialID})
1 Like