Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

acc1211
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.
May 19, 2021

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

Suggest an answer

Log in or Sign up to answer
0 votes
Nic Brough -Adaptavist-
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.
May 19, 2021

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.

acc1211
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.
May 19, 2021

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  .

TAGS
AUG Leaders

Atlassian Community Events