How to set Custom Field value without Issue object using Groovy

Hello!

I have a group picker in Create screen with some logic(Behaviours Groovy script) to filter the values in it and I have to add those filtered values to group picker. This may work using post function (as mentioned in https://www.adaptavist.com/doco/display/SFJ/Set+a+multi+group+picker+custom+field+via+a+post+function) because an Issue object will be created and available by this time.

"issue.setCustomFieldValue(singleGroupCf, [group])"

But in my case, I have this group picker in Create screen and hence, Issue object will not be created yet.

 

Can someone help me in adding the filtered values to group picker without Issue object using Groovy?

Appreciate your help!

1 answer

You can use your code as a post-function in the 'Create' transition. You just have to be aware, that your code will be executed after the first step "1. Create the issue".

Create a new custom script function in the post-function section of the workflow transition and then click on the little arrow on the right side to put the code one step later.

Hi,

Thanks for your reply Thomas.

 

As you said I can put my code as post-function, in general, post-function executes after the transition (in this case Create transition). But my Group Picker is present in Create screen itself. That means the values must be filtered and available in Create screen itself (before the post-function) as per my groovy logic.

If I use 'Issue' object to set the custom field in my logic, the issue object is returning 'null' because the issue bject has not yet created in Create screen (before clicking on Create button).

The other way around I believe, this can be achieved is, we should be able to execute the logic when we click on Group Picker icon. Then it executes my logic and pulls out the filtered data on the Group Picker window. I am not sure how this can be achievable.

 

Thanks!

I am sorry, i missunderstood you.

If you already use Behaviours Groovy Script to filter the values, you should be able to set the value of the formfield with the following expressions:

 

def singleGroupCF = getFieldById("customfield_11111")
singleGroupCF.setFormValue(value)

I hope that this approach will work.

 

Hi Thomas,

I tried the way you mentioned above. Seems the values are being set to the Group Picker field (values obtained from my logic are printing in the log). But when I click on the Group Picker icon, it seems, the Group Picker default query is executing and overriding my values in it. So, by default all the values are populating irrespective of my logic.

So I believe, there needs to be done something when we click on Group Picker icon.

Thanks!

There is currently no way to do it, if i read this correctly:
https://jira.atlassian.com/browse/JRASERVER-61856

This was the raised issue to limit the user picker field to users from certain groups. Took only 9 years to solve.
https://jira.atlassian.com/browse/JRASERVER-7659

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
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

247 views 1 18
Join discussion

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