Return from a server-side script in Behaviours

Is it documented anywhere what a server-side script should return in a Behaviour?

And while I'm asking, what are the expected semantics for returning from scripted conditions, validators and post functions in ScriptRunner? I did check the docs but may have missed this very useful information.

1 answer

1 accepted

0 vote

That is a good but tricky question. The next version will have some static typing smarts so you can see any errors before the script gets executed, unfortunately right now it's not going to help with return types (would be especially useful in script fields).

To try to answer the question:

> what a server-side script should return in a Behaviour

nothing, you change the client by calling methods like getFieldById(..).setFormValue("foo")

Those methods are defined in a superclass of the script but you don't see that... when the script finishes the state is transferred to the client.

> expected semantics for returning from:

  • scripted conditions

For simple scripted condition, which is easiest and recommended, return boolean. For custom script condition, set passesCondition to true or false.

  • validators

Simple scripted validator, return boolean. For custom script validator, return type is ignored, throw InvalidInputException to stop transition. 

  • post-function

return value is ignored

  • script field

A value that is indexed, and passed to the template if one is defined. So the return value should match the indexer and the template. The preview shows you when you have this wrong.

Now that the static type checking work is nearly there, we can show the binding variable names and types, and maybe also the return value.


Thanks, helpful

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

77 views 0 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you