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

Workflow Validator Condition Role

Hello,

 

I am looking to create a validator workflow condition that the current user needs to be in a specific role to be able to create the issue type.  How do I do this?  I think the best way to do this is with the Build-your-own (scripted) Validator (JMWE app).  The name of the role is Product Manager Workflow.

1 answer

0 votes

You did not specify whether you're on Server or Cloud, but since you mentioned "Build-your-own (scripted) Validator" I assume you're on Jira Cloud, correct?

In that case, this is unfortunately not possible until Atlassian implements  https://ecosystem.atlassian.net/browse/ACJIRA-1883

We are on cloud.  Is there another way to validate if its a specific user?  We only want specific users to be able to create the task type.

Yes, you can use:

user.accountId == "<accoutId>"

where <accoutId> can be found using the "Lookup user" button of the Jira expression editor.

For example:

user.accountId == "557058:472c64c9-2567-4213-839b-86bf21558300"

Can you use an or statement lookup multiple user id's?

Absolutely. The or operator is ||

I recommend your read the documentation for Jira expressions, which you can access directly from the editor 

I have one other question.  I am getting the following error message when trying to setup the specific user rule.  How do I set a valid issue key?  Thanks.

Message:
You must provide a valid issue key.

Where are you seeing this error? Using the Test Jira Expression? Did you select an issue on which to test the expression? You must select it even if the expression doesn't depend on the current issue (doesn't use the issue variable).

I am seeing this issue testing the jira test expression.  How do I select an issue to test the expression?  I am new to jira and learning.

When you click on the Test Jira Expression button, you are presented with a dialog box where you can select an issue before clicking on "Test".

Hello David,

I am getting an invalid expression for the following expression:

issue.user.accountId == "5ce30972b588780fd3da994a" || issue.user.accountId == "557058:ecb7be42-714e-40b6-9978-99931be662e3" || issue.user.accountId == "5d8e4849bd42ff0dc9606d5e" || issue.user.accountId == "5aa82e5b33719f2a50160f5c" || issue.user.accountId == "557058:e4d0ef02-efc0-4016-b252-ff190d10ac8e" || issue.user.accountId == "557058:efbfe9ca-f7b8-428a-a8d0-65a912b25384" ||
issue.user.accountId == "557058:ee1f6a66-0290-480b-8800-8b4f5509ac9a" || issue.user.accountId == "557058:2c3bdeaf-3d41-498f-a79e-d77ac1dd0964" || issue.user.accountId == "557058:3c30f2bb-c3ea-459a-a221-370985731101" ||
issue.user.accountId == "557058:bb0cd9a2-333e-4c18-98c1-d55bf61c1312" || issue.user.accountId == "557058:acae3cb9-9280-4360-afae-be46a16c9c4a" || issue.user.accountId == "5c8c4408f2f6ae0dbd038ad6" ||
issue.user.accountId == "557058:4a279262-3c61-4bf6-a202-cd9d108d12bd" || issue.user.accountId == "5c7482759170244d98d821c1" || issue.user.accountId == "557058:2e1f4e1c-83a6-4457-bda1-cec78c86ff2e" ||
issue.user.accountId == "5bc5fc00a994e83f6ee7f94e" || issue.user.accountId == "5c6c567ac6a45773be5fe269" || issue.user.accountId == "5a74857e2aa9952cbfa5702f" ||
issue.user.accountId == "557058:4357f1ee-3937-4323-b26c-21ebe897f755" || issue.user.accountId == "5b92d1d39d17912bf10b0ed0" || issue.user.accountId == "557058:c1881fa0-ca61-44e4-9b3e-8b28682703c1" ||
issue.user.accountId == "557058:5bf00eec-b1b7-4230-8a26-5730e4f2ef15" || issue.user.accountId == "557058:b5a11331-0ebc-4486-8cc2-e7f901e1ffd9" || issue.user.accountId == "5afb7df93278c85a118afee7"

What did I do wrong with the statements?  I am trying to verify only certain users are can create the specific issue.

Hi Philip,

why did you add "issue." in front of "user"? "user" is a context (global) variable, not a property of the issue.

Ok.  I fixed the statement but I get the following error when trying to run the workflow:

The following validator rejected the transition: Build-your-own (scripted) Validator (JMWE app). The configuration is invalid. Contact the app vendor that provided this workflow element.

What am I missing in the statement below?

user.accountId == "5ce30972b588780fd3da994a" || user.accountId == "557058:ecb7be42-714e-40b6-9978-99931be662e3" || user.accountId == "5d8e4849bd42ff0dc9606d5e" || user.accountId == "5aa82e5b33719f2a50160f5c" || user.accountId == "557058:e4d0ef02-efc0-4016-b252-ff190d10ac8e" || user.accountId == "557058:efbfe9ca-f7b8-428a-a8d0-65a912b25384" ||
user.accountId == "557058:ee1f6a66-0290-480b-8800-8b4f5509ac9a" || user.accountId == "557058:2c3bdeaf-3d41-498f-a79e-d77ac1dd0964" || user.accountId == "557058:3c30f2bb-c3ea-459a-a221-370985731101" ||
user.accountId == "557058:bb0cd9a2-333e-4c18-98c1-d55bf61c1312" || user.accountId == "557058:acae3cb9-9280-4360-afae-be46a16c9c4a" || user.accountId == "5c8c4408f2f6ae0dbd038ad6" ||
user.accountId == "557058:4a279262-3c61-4bf6-a202-cd9d108d12bd" || user.accountId == "5c7482759170244d98d821c1" || user.accountId == "557058:2e1f4e1c-83a6-4457-bda1-cec78c86ff2e" ||
user.accountId == "5bc5fc00a994e83f6ee7f94e" || user.accountId == "5c6c567ac6a45773be5fe269" || user.accountId == "5a74857e2aa9952cbfa5702f" ||
user.accountId == "557058:4357f1ee-3937-4323-b26c-21ebe897f755" || user.accountId == "5b92d1d39d17912bf10b0ed0" || user.accountId == "557058:c1881fa0-ca61-44e4-9b3e-8b28682703c1" ||
user.accountId == "557058:5bf00eec-b1b7-4230-8a26-5730e4f2ef15" || user.accountId == "557058:b5a11331-0ebc-4486-8cc2-e7f901e1ffd9" || user.accountId == "5afb7df93278c85a118afee7"

If you "test" the Jira expression in the editor, it'll show a more detailed message: the expression is too long. Atlassian has arbitrarily limited the length of Jira expressions to 1000 characters (among other limitations - see https://developer.atlassian.com/cloud/jira/platform/jira-expressions/#restrictions)

You can shorten the expression by using the "includes" method: 

["5ce30972b588780fd3da994a","557058:ecb7be42-714e-40b6-9978-99931be662e3",...].includes(user.accountId)

(replace the "..." with the missing accountIds)

David,

 

Thanks for the help.  I have one more question.  I am an admin for Jira but I can not see the issues to test the script.  How do I get view access to all issues for the project?

What do you mean by "can not see the issues to test the script"? Can you share a screenshot?

Here are the two errors I get.  The first one is when I try to open up issues for the project.  The second screenshot is from the workflow view.  Do you need anything else?  Thanks.jiraerror.JPGissuescreenshot.JPG

The internal server error is absolutely not normal, especially on the Cloud where apps simply cannot cause them (because no app code runs inside Jira). You need to reach out to Atlassian support.

As for the second screenshot, you should see a list of the last issues you visited. So there is definitely something wrong with your Jira instance. And I guess the first error can explain the empty list (the REST call that fetches the list of issues must be failing).

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Data Center

Introducing Data Center Community licenses

I'm Alison Huselid, Head of Product for Data Center at Atlassian. As we shared in our last post, we’ve been working on a solution for those of you who work for charitable non-profit organizations tha...

180 views 0 16
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