Option List conditional statement

Hi Team,

We created the catalog and added the option list like below:
1.Web 2.app 3.DB based on this selection we are planning to add relative network configuration.
As I tried with this condition I am getting the expected result
“${customOptions.ocategory == 'Web ’ ? ‘web’: ‘app’}”

If I tried with below condition because we required 3 conditions in place but tis not woking.
“${customOptions.ocategory == ‘web’ ? ‘web’: ${customOptions. == ‘app’ ? ‘app’:‘db’}}”

Hello @ibrahim,

There are a few items that I can see that might be affecting your results. There are different ways to perform this. Also, check your caps if they are needed or not.

Using your current example:
"${customOptions.ocategory == 'web' ? 'web': ${customOptions. == 'app' ? 'app':'db'}}"

In the above, you only need one set of ${ }, which everything inside of it will be evaluated as code. Alternatively, you can also use <%= %> instead of ${ }.

Also, It looks like you might be missing the ocategory after customOptions. This is what I would expect a finished item to look like:

"${customOptions.ocategory == 'web' ? 'web' : customOptions.ocategory == 'app' ? 'app':'db'}"

Another way to write this in a more expanded way:

"${if(customOptions.ocategory == 'web'){'web'}else if(customOptions.ocategory == 'app'){'app'}else{'db'}}"

Shorter ways possibly:
"${if(customOptions.ocategory != 'db'){customOptions.ocategory}else{'db'}}"
"${customOptions.ocategory != 'db' ? customOptions.ocategory : 'db'}"

That said, there is another alternative than building in logic, if it is as simple as the above. You can do the following using an Option List:

In the above Manual Option List, it is in CSV format (JSON and others work as well). The first item (before the comma) is what shows in the Input in the UI and the second item (after the comma) is the value that is passed into the variables.

In this case, you would just need to use:

Depending on the choice the user made, it will just fill in the correct value.

Hope that helps!

Thanks a lot for the detailed information its working as expected.

Hi @kgawronski ,

Currently I have created one catalog and based the above options selections network configuration needs to change. So I have modified the network configurations as below:

“network”: {
“id”: “network-5”,
“hasPool”: true,
“idName”: “vxw-dvs-41-virtualwire-96-sid-6087-DEV MORPHEUS DB01”,
“pool”: {
“id”: 8,
“name”: “DEV MORPHEUS DB01”
“network”: {
“id”: “${customOptions.platform == ‘W’ ? ‘network-341’: customOptions.platform == ‘A’ ? ‘network-8’ : ‘network-5’}”,
“hasPool”: true,
“idName”: “${customOptions.platform == ‘W’ ? ‘vxw-dvs-41-virtualwire-97-sid-6088-DEV MORPHEUS WEB01’: customOptions.platform == ‘A’ ? ‘vxw-dvs-41-virtualwire-95-sid-6086-DEV MORPHEUS APP01’ : ‘vxw-dvs-41-virtualwire-96-sid-6087-DEV MORPHEUS DB01’}”,

    "pool": {
      "id": "${customOptions.platform == 'W' ? '6': customOptions.platform == 'A' ? '5' : '8'}",
      "name": "${customOptions.platform == 'W' ? 'DEV MORPHEUS WEB01': customOptions.platform == 'A' ? 'DEV MORPHEUS APP01' : 'DEV MORPHEUS DB01'}"

Post this configuration as I tried to provision it always pick the 1 condition value.For validating this thing I put this value into name I am getting the expected output as name but not sure why its not working on the network side.

Hi @ibrahim,

I did a test here to validate, and I was able to have the network change based on my choice on the input. I’m doing the process slightly differently but this is what I have currently.

Option List:

Catalog Deployment:

Snippet from my Catalog Item:

"networkInterfaces": [
      "primaryInterface": true,
      "network": {
        "id": "<%= customOptions.testnetwork %>"
      "networkInterfaceTypeId": 4,
      "networkInterfaceTypeIdName": "VMXNET 3",
      "showNetworkPoolLabel": true,
      "showNetworkDhcpLabel": false

Note that this is VMware I am deploying in, so it may be slightly different for other clouds. I’ve removed portions of the JSON, as some are not needed. For example, the second option I have is IP Pools, which is a network I have that has an IP Pool attached. I don’t need to include or change these items, because the network has it attached, it will be assigned automatically. I could have left it too, it would not have hurt it.

When deploying, depending on the network I chose, it would deploy to the correct network in my environment.

I’d recommend looking over your Option List and make sure the correct items are being passed. You can try removing the additional items as well, just specifying the id to make it cleaner. Verify the items coming from the Option List matches up to the data in the conditional code.

If you continue to have issues, you may want to use tokens to have us assist directly. Please reach out to your account manager for any questions on tokens usage.

Hope that helps!