Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
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

Scriptrunner: behaviours update field content

Dears,

I am using scriptunner behaviors to update the value of a field, but this new value is not showing.

The fieldtypes I am trying to update are:

  • User Picker (multiple users)
  • Insight Object (single select)

What I am trying is: a.setFormValue("AS-9573")

Am I missing something or doing something wrong?

Kind regards,

 

Matt

2 answers

I would think that there are two issues here.

1) I see that your question is tagged with Jira Service Desk. Unfortunately, there are compatibility issues between behaviours and Jira Service Desk. You can read more about this problem here: https://productsupport.adaptavist.com/browse/SRJIRA-728

2) Your script may be incomplete. Is this the full script you're using? You would need to get the FormField (e.g. def field = getFieldByName("field")) before trying to set the value of it.

Could you clarify whether you are using JSD and explain exactly what you are trying to accomplish?

Also a good point from Josh: Behaviours aren't yet compatible with JIRA Service Desk screens, which may be why you aren't seeing the changes reflected. If you're editing the issue on Jira's normal Create/Edit screens, they should work, though.

Hi Joshua and Johnny,

Thank you for your reply.

What I am trying is to update the approver field with the n+1 of the reporter. The n+1 is stored in Riada Insight.

I used behaviors because this is the only way to trigger on an update field. And indeed on the customer front-end this is not working (JSD). Still it would be useful in Jira.

This is the test-code I have used (not really esthetic in functional correct):

import com.atlassian.jira.component.ComponentAccessor;

def a = getFieldByName("Approver")
def b = getFieldByName("Approvers")
def c = getFieldById("SUMMARY")

log.error("@@@@@@ "+a.getValue())
log.error("@@@@@@ "+b.getValue())
log.error("@@@@@@ "+c.getValue())
c.setFormValue("AS-9573")
a.setFormValue("AS-9573")

log.error("@@@@@@ New"+a.getValue())

 

Jira version: 7.5.0

JSD version: 3.8.2

Scriptrunner: 5.1.6

 

Kind regards,

 

Matt

For a multi-user picker field, you should be able to set it to a list of strings, where the strings are the user keys for the users you want to add to it.

For example,

getFieldByName('MultiUserPickerA').setFormValue(["someuser", 'admin'])

As to the Insight field, I'm trying to reproduce that now. Will update once I've got an answer.

Just as a side note, I haven't quite determined if it's possible to set a custom field from the Insight plugin via Behaviours. I can tell that setting the form value to what looks like the object's unique ID (which seems to be what you're doing with field.setFormValue("AS-9573")) doesn't work.

If you can answer Josh's questions (above) and provide some more detail on what you're trying to do as well as your Insight object configuration, we may be able to assist further.

You may also want to consult our guide on Scripting other plugins at https://scriptrunner.adaptavist.com/latest/jira/scripting-other-plugins.html, as well as Riada's Java API: https://insight-javadoc.riada.se/insight-javadoc-4.0/

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

All you wanted to know about customer support KPIs

When working in customer support, it’s crucial to calculate, analyze and monitor specific numbers, called KPIs (Key Performance Indicators). They go hand-in-hand with customer satisfaction, problem d...

133 views 1 5
Read article

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