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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 for JIRA Cloud Scripted Fields Get Current User

Hi,

I need to get the current user to change the scripted field's content by the current user's group. Some groups should see the raw version of data and some groups should see the calculated version.

I tried this code:

def response = get('/rest/api/2/myself').asObject(Map)
assert response.status == 200

def currentUsername = response.body.displayName

But this response returns the script runner as a user and returns currentUsername as "ScriptRunner for Jira". Is there any other way to get the current user in scripted field. 

1 answer

Hi Gencasysn,

I can confirm that Scripted Fields are always run as the ScriptRunner Add on User as they are loaded and calculated when an issue is loaded.

This means if you need to have a calculated field where the user who runs the script is the user who updates the issue that you will need to use a Script Listener and configure this to be run as the Initiating User in order for it to get the current user who changed content on the issue.

Regards,

Kristian

Hi Kristian,

I need to show this field on the view screen. This means that I can not trigger any event. Actually, I can do it with ScriptRunner Behavior but this feature is not available for cloud. In other words, this field should be seen in view screen and it should change by user's group.

Regards,

Gençay

Hi Gencay,

I can confirm in the cloud version of ScriptRunner that the closest thing you can do is to have a script listener which updates a Jira field as mentioned above and this field can be shown on the view issue screen.

Unfortunately, this is the closest you will be able to get your requirement inside of Jira Cloud due to the fact that Behaviours is not available in the cloud version and due to how Scripted Fields work in the cloud version as explained above.

However, if you would like to have the ability to choose to run a Script Field as the Initiating User then I would ask you to raise a request for this in our public backlog located here so that our product owner can see that this a feature which would be valuable to your organisation.

Regards,

Kristian

Like gencaysyn likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS

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