Need help in workflow validation

Saira September 12, 2022

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

0 votes
Saira September 12, 2022

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

Saira September 12, 2022

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

0 votes
Saira September 12, 2022

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

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 12, 2022

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

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 12, 2022

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 :)

Saira September 12, 2022

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. 

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2022

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).

Saira September 14, 2022

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 ?

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2022

Hi @Saira you have more documentation to Script runner validators here:
https://docs.adaptavist.com/sr4jc/latest/features/workflow-extensions/validators

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

Saira September 14, 2022

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.

Oliver Siebenmarck _Polymetis Apps_
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.
September 14, 2022

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:

issue
.parent
.subtasks
.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,
 Oliver

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
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events