Hello!
I have requirement, if the field have specific value, I have to show or hide other fields on JSM portal. And it works perfectly with usual fields and easy behaviour:
def projectCategory = getFieldByName("Category")
def otherProjectCategory = getFieldByName("Category Name")
def selectedOption = projectCategory.getValue() as String
log.debug "Selected option: $selectedOption"
if (selectedOption == "Other" ) {
otherProjectCategory.setHidden(false)
otherProjectCategory.setRequired(true)
}
else {
otherProjectCategory.setHidden(true)
otherProjectCategory.setRequired(false)
}
But now instead of usual custom field “Category” I need to use Asset field “Category”. But then script is not working.
Is there any way to do it?
The behavior getValue() method on Insight Custom fields, will return the Object's Key (as String), not the label or name of the object.
Also, it might return a single string or an array of strings depending on a few factors.
In the portal, single fields will always return a single string value and multiple fields will always return an array - even an empty field will return an empty array.
In Jira, single fields always return a single string value. Multiple fields will return a string value if the field is empty or contain a single value and they'll return an array when you have more than one value selected.
You can place a simple script on that field to see for yourself what condition returns what
def formField = getFieldById(fieldChanged)
def val = formField.value
formField.setHelpText("$val ${val.getClass()}")
So in terms of your script logic, you either need to lookup the object key that matches "Other" and put that key in your script.
Or deal with the complex insight java api to load the object that match the selected key and read some attribute to base your logic on.
hi there
The above behaviour script works fine in Firefox but in Chrome (127.x update) (using portal), the value received is blank, and yet on Firefox portal the value is retrieved correctly.
Has anyone experienced this issue please. It was working fine before the Chrome update to 127 ran..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.