Why does the condition "cfValues['My Field Name'].getValue() == currentUser" not work?

 

3 answers

I don't thing that currentUser is a valid option. As far as I know, it does not calculate the current user that runs this script. If one of the 'My field Name' options is actually a string that says 'currentUser', then try to add " around this word.

one of the given examples for conditions is:

currentUser == issue.reporter

so imho currentUser is valid... though something is clearly wrong, because like I said, the condition above doesn't work sad

A. please provide more data on what you are trying to accomplish. I assume you are using Script Runner to achieve this task B. You should comment instead of answering, otherwise it's harder to reply in an orderly fashion and keep the order generally within Q&A sites.

Basically what I want is for only the user that is identified in a custom field to be allowed to perform a specific workflow transition. For achieving this I was trying to add a condition to the transition (the condition of the tittle of this thread). Yes, I have Script Runner installed. Thank you for your help!

I'd try if it is better to compare user names (as strings) instead of comparing the complete user objects via equals()?

Something like this (not tested, but you will get the idea):

cfValues['My Field Name'].getValue().name == currentUser.name

 

 

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 Apr 17, 2018 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...

809 views 2 19
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