It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
I am not very proficient in groovy or java, so this is all rather new to me. I have tried to have others look over it, but they see no issues with it. It could just be something small. I guess I just need another set of eyes.
I have a workflow built, but it is not working fully. I cannot figure out a way to do it properly. Most of it works, however, the else is only half working. Basically if they choose anything other than 1,2,3, or null it does the main if thing, but if they do choose 1,2,3, or null it should use the else, but it is not currently. If I remove the "||" and everything with that it works fine, so it is obviously an issue there, I just cannot figure it out.
My logic:
If quantity > 3 OR pickup date - returned date > 14 set Support Group as Desktop - Move/Add/Change
Else set Support Group as Service Desk
My code:
import com.atlassian.jira.component.ComponentAccessor; if ((issue.get("customfield_18370") != "1" && issue.get("customfield_18370") != "2" && issue.get("customfield_18370") != "3" && issue.get("customfield_18370") != null) || (((issue.get("customfield_18372").getTime() - issue.get("customfield_18371").getTime()) / 1000 / 3600 / 24) > 14)){ def optionsManager = ComponentAccessor.getOptionsManager(); def parentOptionObj = optionsManager.findByOptionId(18919); def childOptionObj = optionsManager.findByOptionId(19047); Map<String,Object> newValues = new HashMap<String, String>(); newValues.put(null, parentOptionObj); newValues.put("1", childOptionObj); return newValues; } else{ def optionsManager = ComponentAccessor.getOptionsManager(); def parentOptionObj = optionsManager.findByOptionId(19044); Map<String,Object> newValues = new HashMap<String, Object>(); newValues.put(null, parentOptionObj); return newValues; }
I was wanting it to run the else if the user selects 1, 2, or 3 OR pickup date - returned date <= 14. I had thought that's what my logic was because of the or in the if statement? If not, what do I need to change to make it reflect that?
You need an AND, not an OR:
if (quantity > 3 AND pickup date - returned date > 14) set Support Group as Desktop - Move/Add/Change else set Support Group as Service Desk
because (according to your latest response), if pickup date - returned date <= 14, you want to hit the "else" regardless of the quantity. So the first case is only when pickup date - returned date > 14 and quantity > 3
Thanks for the response. I see I misspoke previously. I think this issue might be due to leaving the date null in testing. I thought that would be covered in the else though. If I add the date != null in the else, or make it an else if rather, it should work I think.
The below is just to clarify where I previously misspoke.
So I still want the first case to occur if quantity is > 3 OR pickup date - returned date > 14
Then the else for if quantity is <= 3 OR pickup date - returned date <= 14
I tried doing separate post functions, but the order of them overwrites the result, which is not my intention. I guess I could try doing a series of else if statements? I just thought my current way would do all that I wanted since I have the or.
My thinking was it would see if the quantity was > 3. If so, set the result, if not, move on to see if the dates is > 14. If so, set the result, if not, move to the else. I would only want to trigger the else if both of the above are false.
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreAtlas Camp is our developer event which will take place in Barcelona, Spain from the 6th -7th of September . This is a great opportunity to meet other developers and get n...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.