Help with Behaviour Script set field

Junaid Shah
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.
July 28, 2015

Hi, I need help with the script runner plugin..

I'm not to sure how to code this but I am trying to populate a user field based on a text field that is already populated and visible within View, e.g. TextField = A, Userfield = a@example.com.

 

I understand the behaviour plugin can be used to do this , I am running JIRA v5.2, Behaviours V0.5.3 and Script Runner V2.1.15.

Another question was scripted fields and the coding style/syntax, how different is it compared to the server side scripts written within the behaviours. e.g. if I have a working scripted field, can I move the code from there to the server side script without any issues?

 

All help is very much appreciated.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
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.
July 28, 2015

Can you describe what you're trying to do? It sounds like the user picks a user, and you want to show their email address?

> can I move the code from there to the server side script without any issues?

not trivially, no.

Someting like this:

def managers = [
    "AMER": "bob@example.com",
    "EMEA": "steve@example.com",
]

def managerField = getFieldByName("Manager")
def regionField = getFieldById(getFieldChanged())
managerField.setFormValue(regionField.getFormValue())

You add this behaviour to the Region field or whatever, so when it changes this code is called.

 

Junaid Shah
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.
July 28, 2015

Hi Jamie, basically I have 4 regions EURO, AMERICA, ASIA, and AFRICA which are displayed in a text field per issue, these are picked on the Create Screen. which is then in the status Open, I have a transition called Start Progress which puts the status in Start Progress, during this transition I need to send an email, to the manager of that specific region, (EURO AMERICA ASIA Or AFRICA) Dependent on the region that is chosen.. So that is why it will be adding an email address to a user field or text field which the post function can use to send an email to.

Junaid Shah
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.
July 28, 2015

Your help is very much appreciated..

Junaid Shah
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.
July 31, 2015

Hi Jamie, tested your code today and it seems to be retrieving the value of the select list value ID's instead of the fixed email address? (e.g. in Managers if AMER is selected them it will display 17691 (Which is AMER's Value ID))

Junaid Shah
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.
July 31, 2015

Also since the field Region is auto populated during Create is it possible to retrieve the value through transition and update the manager field accordingly?

Junaid Shah
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.
July 31, 2015

To update when used in a text field it is simply duplicating the value.. e.g. If A is entered then Manager value is A

TAGS
AUG Leaders

Atlassian Community Events