How to get the cloud name in Forms

Hi Team,

I have created the forms and added the two-option list one is group, and another one is cloud. based on the group selection its populating the cloud.

In my backend flow I am expecting to pass the Cloud-name instead of ID. If I am using the below one, I am only getting the ID of the cloud.
cloud=“<%=customOptions.cloud%>”

Hi,

You can achieve this by creating a new Option List with the configuration below:

  • Type: Morpheus Api
  • Option List: Clouds
  • Translation Script:
var results = [];

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

It would produce an Option List containing a dataset like this:

[
  {
    "name": "aws",
    "value": "aws"
  },
  {
    "name": "XCP-NG-QA",
    "value": "XCP-NG-QA"
  },
  {
    "name": "additional cloud",
    "value": "additional cloud"
  }
]

Thanks @Uthman_Eqbal …I have already applied the same but here the challenge is we need to show only specific clouds like azure or aws which is available in the forms if we go on this way we are not able to access that feature.

@ibrahim

You can only get the cloud ID using the form method. If you are trying to ensure something like “'Only return Amazon type clouds”, you could do something like this in the option list translation script.

var i=0;
results = [];
for(i; i<data.length; i++) {
  if (data[i].zoneType.code == "amazon") {
  results.push({name: data[i].name, value: data[i].id});
}
1 Like