Catalog config for DHCP/Static VLAN

I have created catalog which the user can select between dhcp / static enabled networks.

I’m trying to then pass that on to the config in the catalog under:

networkInterfaces: [
{
primaryInterface: true,
network: {
id: “<%= customOptions.parsedNetwork %>”,
hasPool: false,
idName: PR25.2
},
ipMode: “”,
showNetworkPoolLabel: false,
showNetworkDhcpLabel: true
}

Changing to:

networkInterfaces: [
{
primaryInterface: true,
network: {
id: “<%= if (customOptions.input_vm_networkoptions == ‘NO’)(customOptions.parsedNetwork) else {if (input_vm_networkoptions == ‘YES’)(customOptions.parsedNetwork2)} %>”,
hasPool: false,
idName: PR25.2
},
ipMode: “”,
showNetworkPoolLabel: false,
showNetworkDhcpLabel: true
}

However it fails with failed to create server: Cannot set property ‘name’ on null object

parsedNetwork is the fieldname of the DHCP Vlan selected.
parsedNetwork2 is the fieldname of the static Vlan selected.

I don’t believe the value is working, any ideas why it’s failing?

Also I have another field generated for an IP address if static vlan selected.

I presume if I add “ipAddress” within networkinginterfaces, would this be suffient or are there other fields required?

networkInterfaces: [
{
primaryInterface: true,
network: {
id: “<%= if (customOptions.input_vm_networkoptions == ‘NO’)(customOptions.parsedNetwork) else {if (input_vm_networkoptions == ‘YES’)(customOptions.parsedNetwork2)} %>”,
hasPool: false,
idName: RP25.2
},
ipMode: “”,
showNetworkPoolLabel: false,
showNetworkDhcpLabel: true
ipAddress: “<%= customOptions.vm_ipaddress %>”
}

Managed to figure the syntax to my first question it’s

“<%= if (customOptions.input_vm_networkoptions == ‘NO’){customOptions.parsedNetwork} else {if (customOptions.input_vm_networkoptions == ‘YES’){customOptions.parsedNetwork2}} %>”

My other question about IP addresses, what fields need to be populated in the config to apply a static IP? Is it just “ipAddress” ?

Assuming this is for vCenter, you should only need:

networkInterfaces: [
{
primaryInterface: true,
network: {
id: 
},
ipMode: “”,
ipAddress: “”
}

Note, different clouds may have different requirements. Azure you would define a vnet and subnet in most cases.

For ipMode you should either map or have a select list that has:

'Default','""'
'Static','static'
'DHCP','dhcp'