Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get Error Messages/Output (SCRIPTRUNNER)

The situation I have is as follow:

I need to wipe out the fields in a behavior when a new dropdown is selected. The problem is whenever I click create button and an error exist on the form it is wiping out the fields for some reason, even though I am checking for "getFieldsChanged()". I just figured at this point, an easy workaround is to check for any errors that would be returned and if some errors are returned, I'll just build an exception where the clear fields function is called. I have no idea how to get the error returned though... Is anyone able to provide me syntax on how to do this? This is what I've got going so far but the list is empty.

 

def jiraServiceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection())

def errorList = jiraServiceContext.getErrorCollection()

log.debug(errorList.dump()) // currently outputting {}

 

Much appreciated

Harvey

1 answer

Only ERROR level of "log" is logged by default. So

log.error(...)

function should work.

Or you need to setup logging level first using

log.setLevel(Level.DEBUG)

as described here

I have no issue outputting logs. Before I run my script I do

log.debug("START SCRIPT") 

which output no problem. But I need to catch errors returned on a create submission that fire back off because of validation results, read and interpret those results to help the user with the next time they try to hit the create button. I am doing this by refining the choices in the checkbox list.

Hi @Harvey Bennett , oh, ok, I understand now. But unfortunatelly I never tried to get errors this way. But I think that any "error collection" is filled in with data when Validators are executed and validators are executed when transition is executed. So you would need to validate validators any time the fields on the screen are changed.

I remember we used this method to validate transition

https://docs.atlassian.com/software/jira/docs/api/7.4.0/com/atlassian/jira/bc/issue/IssueService.html#validateTransition-com.atlassian.jira.user.ApplicationUser-java.lang.Long-int-com.atlassian.jira.issue.IssueInputParameters-com.atlassian.jira.workflow.TransitionOptions-

So it might help a little, but it will be still quite complicated code.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you