You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.