Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,348
Community Members
 
Community Events
184
Community Groups

validate radio box in custom field validator script.

I need to ask after a condition if some radio buttons  fiels are filled.

I dont' want to user the simple scripted validator. Because I will need create a lot of them.

How I can do a validator using a custom script validator???

cfValues doesn't work in custom script validator. And I have an error hen the fiels are empty because I can't get a null value into a variable.



thanks in advance.





1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 09, 2018

I think it would be something like this:

def cs = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("FIled Name")

if (issue.getCustomFieldValue(cs) == null) {

// throw error

}

Thanks Alexey.

I have this code.

def browse = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Can you browse the Internet?")

 

if (vpnproblemtype == "It's a VPN issue"){
if (issue.getCustomFieldValue(browse) == null){
throw new InvalidInputException("browse", "Field empty")
}
}

 

The code is running well. But I can't see the error message in the Service desk customer portal.  Do you jnow how to display a message in the customer portal?


thanks in advance.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 09, 2018

I never tried validators for portals. Anyway I would make sure that your code throws the error by adding logging.

def browse = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Can you browse the Internet?")

 

if (vpnproblemtype == "It's a VPN issue"){
if (issue.getCustomFieldValue(browse) == null){
log.error("error logged")
throw new InvalidInputException("browse", "Field empty")
}
}

Could you have a look in the atlassian-jira.log if the error message is printed out?

 throw new InvalidInputException("Field empty") 


 without the field is working. but I need to send the error message to the fied.  I'm tried without the quotation mark. but The message is doesn't show

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events