Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,555,974
Community Members
 
Community Events
184
Community Groups

Date value should be selected after X days if I select a value in above dropdown field

We have Location field as drop-down field and date field. here we need if I select value XXX from Location the date field should be selected after 10 days and If I select YYY in the location the date field should be selected as 5 days after the current date. 

We are using JMWE any script can be shared which suits for this condition

Thanks,

Ajay

1 answer

1 accepted

0 votes
Answer accepted
David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 28, 2022

Hi @Ajaygoud Gaddam ,

you can use a Set Issue Fields post-function, select the date field as the field to set, and use a Nunjucks script like this:

{% if issue.fields.customfield_12345.value == "XXX" %}
{{now | date('add',10,"days") | date}}
{% elif issue.fields.customfield_12345.value == "YYY" %}
{{now | date('add',5,"days") | date}}
{% else %}
{{now | date('add',1,"days") | date}}
{% endif %}

Hi @David Fischer _Appfire_ ,

Thanks for the prompt response.

Here is some more info for your understanding. 

* The date field is mandatory in the Create screen, so hope it should be resols with validation

* The date field should not be filled automatically to the 10, 5 days it should be greater than 10, 5 day of current date and it should be filled within creating the ticket.

It should show an error if they select within the range.

Hope this will help with the next suggestion.

Thanks,

Ajay

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 28, 2022

Oh, so if I understand correctly, you're trying to validate the field, not set it, correct?

In that case, you need to create a Build-your-own Validator with a Jira Expression like this:

!issue.customfield_12345 || !["XXX","YYY"].includes(issue.customfield_12345.value) ||
issue.customfield_12345.value == "XXX" && issue.customfield_67890 > new CalendarDate().plusDays(5) ||
issue.customfield_12345.value == "YYY" && issue.customfield_67890 > new CalendarDate().plusDays(10)

where  customfield_12345 is the single-select field and customfield_67890 is the Date (only) custom field.

Hi @David Fischer _Appfire_ Thanks again,

As I am completely new to scripting I didnt see were i am missing something. In the JMWE validator i have tested the expression and it shown the true valu as it fine but while creating the ticket even if we select date not in range too the ticket is not being submitted and showing the custom error what we added in the validator error.

attaching the script and logs down


!issue.customfield_10059 || !["Beijing","Berlin","Hamburg"].includes(issue.customfield_10059.value) ||
issue.customfield_10059.value == "Beijing" && issue.customfield_10060 > new CalendarDate().plusDays(5) ||
issue.customfield_10059.value == "Berlin" && issue.customfield_10060 > new CalendarDate().plusDays(10)

create.pngerror.pngscrpt.png

As I tried date field above and my requirement should be for date and time field will you please suggest next expression for date and time field.

Thanks,

Ajay

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 02, 2022

Hi @Ajaygoud Gaddam ,

since it's a Date custom field, Jira Expressions don't return a CalendarDate object but a string (for no good reason).

Try this:

!issue.customfield_10059 || !["Beijing","Berlin","Hamburg"].includes(issue.customfield_10059.value) ||
issue.customfield_10059.value == "Beijing" && new CalendarDate(issue.customfield_10060) > new CalendarDate().plusDays(5) ||
issue.customfield_10059.value == "Berlin" && new CalendarDate(issue.customfield_10060) > new CalendarDate().plusDays(10)

Many Thanks @David Fischer _Appfire_ ,

It works for Date custom field could you please suggest what should be added to the above expression for Date and time field.

It would be really appreciated if I would get expression for Date and time custom field.

Thanks again in advance.

Ajay

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 03, 2022

Hi @Ajaygoud Gaddam ,

I'm glad it works. For a date/time custom field, just replace CalendarDate with Date everywhere.

Super It works, Thanks for the help @David Fischer _Appfire_ 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events