Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Need help in workflow validation

I want to compare the field named Scheduled start date with current time and prevent transition if this condition is not true. But when I put it in the workflow validator, it does not prevent going forward Screen Shot 2022-09-12 at 10.22.17 AM.png

3 answers

I did publish my workflow Screen Shot 2022-09-12 at 1.22.25 PM.png

If you see Actual Start date ie is earlier than scheduled start date, this should not be allowed. I'm also setting Actual start date in post function when the user goes to In Progress. Not sure if that helps you analyze the problem

Can you send me a snap of what error it shows when you try to transition? It's supposed to prevent you from transitioning

Hi @Saira , I just tested it on cloud and it works correctly for me. Did you publish your updated workflow? :)

Hi @Saira , sure, the error message looks like:

Screen Shot 2022-09-12 at 22.33.07.png

But I think your configuration is wrong. Your configuration is

  • IF scheduled start date and time IS GREATER THAN now, than let the validation pass

If I understand it correctly, you need the oposite

  • IF scheduled start date and time IS LOWER THAN OR EQUAL now, than let the validation pass

Let me know if it works :)

I will try it , but before I do, how do I add a custom error message instead of the default one? this is what I want to display

You cannot work on this issue until the scheduled start date has arrived. 

Hi @Saira unfortunatelly you cannot add custom message to this validator. In this case you would need to install some App from Marketplace which has custom validator implemented (I know ScriptRunner can do it).

Thanks. I actually do have Scriptrunner. I also have one more question

I have a parent issue that has two subtasks - suppose task A and task B

I want task B's assignee to not be the same as task A's. Task A has a label, let's call that X.

How do I write a scriptrunner script to restrict transition of task B if task A and B have the same assignee ?

Hi @Saira you have more documentation to Script runner validators here:

Can you check it and try to write some script and get back to me with some basic snippet of the code?

Thanks, here's what I need:

issue.parent."subtask with the label".assignee.accountId != issue.assignee.accountId


but I don't know what to put in place of "subtask with the label". 


Basically, I need to retrieve the subtask that has that label, and then compare that subtasks's assignee to the current issue's assignee. The doc's don't really help much here.

Hi @Saira ,

For any validator in any cloud app, you would use Jira Expressions. What you've written is already almost what you need :) 

The subtasks attribute is a list that contains all subtasks. You only want the one with a certain label, so you'll have to filter it. This can be done like this:

.filter( st => st.labels.includes("label_X")[0]
.assignee.accountId != issue.assignee.accountId

Please note the [0] at the end of the filter() function: filter() returns a list because you could potentially have more than one subtask with that label. If you are certain that it's really only ever going to be the one subtask, you can pick the first one from the list with [0].

Hope that helps,

P.S. Jira Expressions are a fantastic way not only to build conditions and validators, but also to play around with issue data and even aggregate data from multiple issues. If you like them, let me recommend our free app Expression Tester, that lets you play around with Jira Expressions right from the UI.


Suggest an answer

Log in or Sign up to answer
Site Admin

Atlassian Community Events