Extract and convert string from input

Hi,

Can we extract and convert the user input string without using the option list?

For example, the user provides the input “Digital Service”. In the backend, will extract only some characters “DS” and convert to new string and use in service catalogue json.

Thanks,
Aung

Anything between <=% and %> is groovy syntax. So regex could be applied to your customOption.fieldName to select only the first character of each word.

Might be able to do (with a quick google):

<%= customOptions.fieldName.replaceAll(/\b\w/g) { it[0] }.toUpperCase() %>

2 Likes

Thanks for your feedback. I used the above syntax with a custom input field name in the instance naming section of the service catalog. However, Morpheus threw a gasket error when we ordered the service catalog.

Thanks,
Aung

It’s possible there may need to be alternate quoting on the objects (or ways of parsing). I simply grabbed the first example of regex with groovy to highlight a way forward.

1 Like