Hi Team,
There are two custom fields Start date and Star quarter.
Start Quarter values are Q1 24, Q2 24, Q3 24, Q4 24.
whenever user select a date in Start date and if it falls under first quarter of the year (Consider January to March) then Start quarter field value to be set to Q1 24.
if it falls under second quarter of the year (Consider April to June) then Start quarter field value to be set to Q2 24.
Similarly for July to Sep then Q3 24, Oct to Dec then Q4 24
Please help with Behavior script
Thanks,
Venkatesh
document.addEventListener("DOMContentLoaded", function() {
const dateInput = document.getElementById('date');
const selectList = document.getElementById('selectList');
dateInput.addEventListener('change', function() {
const selectedDate = new Date(dateInput.value);
// Define your date range conditions
const startDate1 = new Date('2024-07-01');
const endDate1 = new Date('2024-07-10');
const startDate2 = new Date('2024-07-11');
const endDate2 = new Date('2024-07-20');
const startDate3 = new Date('2024-07-21');
const endDate3 = new Date('2024-07-31');
// Example condition: if selected date is within the range
if (selectedDate >= startDate1 && selectedDate <= endDate1) {
selectList.value = "option1"; // Set your desired option value for this range
} else if (selectedDate >= startDate2 && selectedDate <= endDate2) {
selectList.value = "option2"; // Set your desired option value for this range
} else if (selectedDate >= startDate3 && selectedDate <= endDate3) {
selectList.value = "option3"; // Set your desired option value for this range
} else {
selectList.value = "default"; // Default option value if date is outside all ranges
}
});
});
document.addEventListener("DOMContentLoaded", function() { const dateInput = document.getElementById('date'); const selectList = document.getElementById('selectList'); dateInput.addEventListener('change', function() { const selectedDate = new Date(dateInput.value); // Define your date range conditions const startDate1 = new Date('2024-07-01'); const endDate1 = new Date('2024-07-10'); const startDate2 = new Date('2024-07-11'); const endDate2 = new Date('2024-07-20'); const startDate3 = new Date('2024-07-21'); const endDate3 = new Date('2024-07-31'); // Example condition: if selected date is within the range if (selectedDate >= startDate1 && selectedDate <= endDate1) { selectList.value = "option1"; // Set your desired option value for this range } else if (selectedDate >= startDate2 && selectedDate <= endDate2) { selectList.value = "option2"; // Set your desired option value for this range } else if (selectedDate >= startDate3 && selectedDate <= endDate3) { selectList.value = "option3"; // Set your desired option value for this range } else { selectList.value = "default"; // Default option value if date is outside all ranges } }); });
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi and welcome to the Community!
If you want to make this flexible, try using a lookup table in automation. What the rule will do:
The rule ( i have used manual trigger and due date field, but you can change to fit your needs):
The lookup table in the first action:
The extract the quarter and put in a variable together with the year:
Several things happening here:
Now all you have to do is add an action step, editing the issue and setting the select field with the quarter variable.
Good luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Jeroen Poismans , I have tried to create lookup table in automation, but the suggested lookup table is not available in Automation. we are using 9.10.1 Jira version. Please help.
Regards,
Venkatesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, so I modified the rule so you it should work in your version:]
{{issue.duedate.format("M")}}
Q1 {{issue.duedate.format("YY")}}You should change this to the Edit issue action, to edit and set your select list.
Jeroen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jeroen Poismans , There is no "Create variable" Action in my version 9.10.1.
Please suggest an alternative way.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Below is the behavior script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you sure about that Create variable option? I am on 9.4.X and it is there:
Regards!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jeroen Poismans , Yes it is there in Prod but not in UAT even though both the environments are running on same version.
Could you please tell me what the month variable is holding smart value?
Thanks,
Venkatesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I use this expression:
{{issue.duedate.format("M")}}
It extracts the month number.
Jeroen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.