Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Validation in due date on issue update event

Kalyan Kumar Das
Contributor
December 24, 2019

I have applied the validation in due date field at the time of issue created event.

Logic:

When the ticket<task issue type> is created and due-Date is set to 10th January 2019. Then  Due Date <sub-task issue type> should be smaller than Due-Date<task issue type>

The validation rule is working fine at the time of creating the sub-task issue created event. 

The condition is provided below :

if(issue.parentObject.dueDate >= issue.dueDate )
{
issue.dueDate
}

But the validation is not working at the time of issue update event.

Also I am unable to apply the validation in due date field at the time of issue update event.  

Can anyone help me where and how to apply validation in issue update event. So that the validation will be working fine for issue update event.    

1 answer

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 3, 2020

Hi Kalyan,

If I understand your concern here, you have a workflow validator working when executing a transition that creates sub-tasks, but you also want this validator to be applied to issue update events that happen outside of a transition.

Unfortunately, the validators in Jira only are expected to work within the steps of a workflow (just before a transition is executed to be more precise).  More details on these can be found in Advanced Workflow Configuration: Validators

The way I would recommend trying to address this problem would be to adjust the screen configurations here.  If you remove that field from the view/edit screens of that issue type, and only leave that field on a transition screen, you can effectively prevent your users from just making changes to the field outside of the transition itself.  If your transition does not yet have a screen, you would have to create a new screen here and place that field in the screen.  This way users could still input data to that field and have it validated, but only immediately before a transition happens.

If you are unfamiliar with making a change like this, I would recommend that you consult the documentation Defining a screen.

I hope this helps. Let me know if you have any questions or concerns about this approach.

Andy

Kalyan Kumar Das
Contributor
January 6, 2020

@Andy Heinzer:

Thank you so much for sharing the answer. I will implement as per your steps provided. But the only question i am having issue update permission that how to handle the permission scheme?By default, jira is not validating any custom field when agent click on edit button.  

Would you please check i had implement the script on script listener but i am facing issue on the same. I m searching for 4 days.

The two point is provided below which i need to fix:

1. I am unable to restrict for update the value of an issue at the time of issue update event. I had created a script on script listener.

2. Instead of hard coded value for key, i want to use dynamic code on script-runner. Means if the ticket is sub-task issue and project will be the same then the below script will execute.

Here the script is provided below and the requirement is duedate value for Task IssueType should be greater than the Duedate value for n number of subtask IssueType :

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import groovy.transform.BaseScript
import com.onresolve.scriptrunner.runner.customisers.ContextBaseScript
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.opensymphony.workflow.InvalidInputException

//

@BaseScript ContextBaseScript script

Issue issue = getIssueOrDefault("TEST-258") // Hard coded issue-key defined

if(issue.parentObject.dueDate.compareTo(issue.getDueDate()) >= 0)
{
UserMessageUtil.success("Due Date Success"+issue.dueDate)
log.debug(issue.getDueDate())
}
else
{
UserMessageUtil.success('Please enter the Subtask duedate that is less than Parent-Task Due-Date ')
//throw new InvalidInputException("Input not valid")
}

The problem is that when the condition fails then the Due-date will be update first and next the pop up alert is raised which i mentioned in the code but I am unable to restrict the due date update.

Also recommend us for second point on run-time environment(on production).

Due_Date_code_Listener.jpgTEST-247.jpgTEST-258.jpg

Suggest an answer

Log in or Sign up to answer