Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scripted update field value realtime

Gleb Kartashov
Contributor
November 17, 2021

Hi

I need to update a customer portal field value using groovy based on a different field value. 

When a customer on fills in field A, field B value should be set using groovy script.

I tried using Automation for Jira but it only lets you set field B value to a constant, my value should be calculated by Groovy script. I also tried using Run a Script (Scriptrunner action in Automation) but I only managed to set value after the issue was created, not in realtime.

Is this possible in Jira?

1 answer

1 accepted

0 votes
Answer accepted
PD Sheehan
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 22, 2021

If you have scriptrunner, the only option for real-time update option is with Behaviours.

If you create a behaviour configuration and map your service desk project and the appropriate request type, you can then add your field A to the behaviour configuration.

In the field A behaviour config, click the Add a Server-Side script and then write your groovy script. Depending on the type of fields for field A and B and what values in A should trigger what value in B, the script may be more or less complex.

Gleb Kartashov
Contributor
November 23, 2021

Thanks. 

Can I use it with Insight Object\s field though? This is what I got: 

CIField = Form field ID: customfield_10123, value:

CIValue =

Behaviour code:

def CIField = getFieldByName("insight object")
log.error('CIField = '+CIField)
def CIValue = CIField.value
log.error('CIValue = '+CIValue)
Gleb Kartashov
Contributor
November 23, 2021

Ok this works for Insight fields also. It just returns field value as String, not as ObjectBean

Thanks

PD Sheehan
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 23, 2021

Just a heads up about behaviour and insight field.

If the field contains a single object, the value will be a string with the object key.

If the field contains multiple objects, the value will be a list of strings (each with the object key).

This is independent of whether the field allows 1 or multiple. In other words, an insight field that allows multiple but only has 1 selected will return the same data as an insight field that allows a single value only.

Suggest an answer

Log in or Sign up to answer