Custom info on transition screen [Behaviours and Script Runner]

Tomasz Stec
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.
November 24, 2014

Hi,
I am facing an unusual problem right now related to Behaviours(Script Runner) plugin. I need to display an info or so called warning at the top of the transition screen. I already tried to use Behaviours validator which looks like this:

FormField field = getFieldById("customfield_XXXXX");
field.setHelpText("My warning message !!!");

The problem is it displays an info below the form field which does not satisfy me. I had  an idea which corresponds to Script Runner's 'Custom Validator Script'. It can throw InvalidInputException. I remember that InvalidInputException can be instantiated with 'field name' and 'error message' so it's 'error message' is displayed below the field. BUT if you pass only 'error Message' it will be shown at the top of the screen.


My questions are: Is there a way to display some message at top (above all screen fields) of the screen and if so, how to do it in groovy ? Am i thinking right to use InvalidInputException ?

Thanks,

Tom

2 answers

1 vote
JamieA
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.
November 25, 2014

Use a workflow validator if you want to do this, don't use behaviours. If you use a validator then yes you throw an InvalidInputException.

Tomasz Stec
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.
November 25, 2014

The problem is if i use workflow validator the message will be shown after user clicks button to close (validate form) screen. And i need the message to be shown straightaway the transition screen apprears.

JamieA
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.
November 25, 2014

That's true. I would just put the message under the summary... currently behaviours doesn't have support for sticking the message at the top.

Tomasz Stec
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.
November 25, 2014

Thanks, Jamie. Now i'll try non proffesional way :) : put some javascript as help text (setHelpText()) with Behaviours.

0 votes
Tomasz Stec
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.
November 25, 2014

I did it with help of jquery:

image2014-11-26 10:32:26.png

And with this code used as Behaviours validator script:

FormField assignee = getFieldById("assignee");
String js = "<script>\n"+
    "AJS.\$(document).ready(function(){\n"+
    "AJS.\$(\"#assignee-container\").before(\"<div id=\\\"title-container\\\"><span>This transition is for authorized users only !</span></div>\");\n"+
    "AJS.\$(\"#title-container span\").css(\"color\",\"red\");\n"+
    "AJS.\$(\"#title-container\").css(\"text-align\",\"center\");\n"+
    "AJS.\$(\"#title-container\").css(\"border\",\"1px solid red\");\n"+
    "});\n"+
    "</script>";
assignee.setHelpText(js);

Edit:
Too fast... Now Behaviours can not let me pass the transition and every time i try to close the screen it shows alert:
image2014-11-26 10:54:28.png

JamieA
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.
November 25, 2014

That's pretty cool, although horribly unmaintainable ;-) Can't help thinking you just need a condition though.

Tomasz Stec
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.
November 25, 2014

Any idea why Behaviours keeps showing this alert ?

JamieA
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.
November 25, 2014

This happens if you try to submit when it's in the process of sending a request. Try putting the behaviour not on the assignee, but on some field that's not likely to change. I think you can put it on the project.

Suggest an answer

Log in or Sign up to answer