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

i need to populate a customfield which is user picker from scripted field

So what i am basically trying to do is create a scripted field and write certain condition in that scripted field and when certain event for example edit happen on the issue this script runs and then it will allow the user based on the condition in the scripted field to send this value "the user " into the user picker . so now i want to be able to populate the user picker custom field from the scripted field with the user value when ever the condition is true .

Hope i didnt confuse .

1 answer

0 votes

This is not quite what "Scripted field" means in Scriptrunner.  In SR, a scripted field is static data that is calculated and displayed, it's not setting a field.  Scripted fields are their own type of field, they're not "user pickers", "text", "date" etc.

So, there's three parts to the script you need to put together, which I'll extract from your question:

>when certain event for example edit

That tells us you need a scripted listener - this can catch an event and run a script if appropriate.  Sample listener code here: https://library.adaptavist.com/entity/update-the-value-of-a-custom-field-using-a-listener

>allow the user based on the condition

I can't help much with that, you've not defined the condition, but it should not be too hard to script - it's probably going to be nothing more complex than the listener code with "If {condition} then {change data in user picker}"

>populate a user picker

There's a generic script for setting all the custom field types at https://library.adaptavist.com/entity/update-the-value-of-custom-fields-through-the-script-console  - just take all the "user picker" related lines from that.

Thank you for the reply @Nic Brough _Adaptavist_  . So basically we have behaviour in the Script runner to restrict certain action . which is not working in my case when the jira instance is being used from the mobile application , so i thought about writing a scripted field which captures the event of edit , get the operating system info and  if (operating system =android ) it should be null and if it gets through the condition it should populate the user picker with the current user in the custom field which is used in the permission scheme of the project so he is able to edit .

so is the above scenario possible ? as i have been looking for something which will help me out but couldn't find anything until now  .

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Do you use Jira Cloud with Microsoft Teams?

Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...

42 views 0 3
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