Need help on Date Validation

Selvakumar, Shrinidhi October 22, 2024

If the change category (custom field xxx) is "abc" or "xyz":

  • The end date (custom field aaa) should be less than or equal to 20 days from the start date (custom field bbb).

For any other category:

  • The end date (custom field aaa) should be less than or equal to 2 days from the start date (custom field bbb).

 

I tried both below scripts with build your own validator

Trial 1

if (issue.customfield_xxx?.value == "abc" || issue.customfield_xxx?.value == "xyz")

{

return issue.customfield_aaa <= (issue.customfield_bbb + "20d");

} else {

return issue.customfield_aaa <= (issue.customfield_bbb + "2d");

}

Trial 2

(issue.customfield_xxx!= null && (issue.customfield_xxx[0].value == "abc" || issue.customfield_xxx[0].value == "xyz") && (issue.customfield_bbb != null) && (issue.customfield_aaa != null)

(issue.customfield_aaa[0].value <= (issue.customfield_bbb[0].value + (20 * 24 * 60 * 60 * 1000)))

Both throws error even I set date below 20 days. Can someone please spot what I am missing

Note: I am trying this in Workflow validator

1 answer

0 votes
Marc - Devoteam
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.
October 23, 2024

Hi @Selvakumar, Shrinidhi 

As this is not ootb standard functionality within Jira, what 3rd party marketplace app is used to construct this custom validator?

This will help community members, based on experience with the 3rd party app if they will be able to assist

Selvakumar, Shrinidhi October 23, 2024

I am not using any 3rd party app. I tried in Workflow --> Validator --> Build your Own Validator

Marc - Devoteam
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.
October 23, 2024

Hi @Selvakumar, Shrinidhi 

This type of validator comes from a 3rd party app, this is not an ootb function of Jira

These are the default ootb validators in Jira:

Screenshot 2024-10-23 at 09.57.27.png

 

 

Selvakumar, Shrinidhi October 23, 2024

Oh, Got it, we are using JMWE app (1st option)Screenshot 2024-10-23 at 1.30.30 PM.png

Marc - Devoteam
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.
October 23, 2024

Hi @Selvakumar, Shrinidhi 

Now comes my real question.

What is the validation used for, preventing transition to a next state?

A workflow validator acts on information in the field, as you mention you update the field, this seems more like an automation rule should be set in place to monitor the field values.

Or is this field on a transition screen only and used in a single transition to be checked and not editable, but only viewable on the issue screen?

Selvakumar, Shrinidhi October 23, 2024

Hi @Marc - Devoteam 

 

I am not updating automatically. I am writing script to Validate the below,

  1. For Categories "abc" or "xyz":

    • Validate that the updated end date (custom field aaa) is less than or equal to 20 days from the updated start date (custom field bbb).
  2. For All Other Change Categories:

    • Validate that the updated end date (custom field aaa) is less than or equal to 2 days from the updated start date (custom field bbb).

The Context is This validation should occur when the user updates both the start date and the end date, ensuring that the new values meet the specified requirements.

Like Marc - Devoteam likes this
Marc - Devoteam
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.
October 29, 2024

HI @Selvakumar, Shrinidhi 

I'm not able to figure this out as well

Conditional logic should be possible, according to documentation, Conditional+execution 

@David Fischer {Appfire} Could you help out in this request?

I would be interested to se this solved, if possible.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events