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; }
It is just when you select a quantity < 3, but leave the the dates blank that was causing an issue. I had a clause in there for if the quantity was null, but not the dates.
And which combination of quantity and duration is not currently working the way you expect?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A smarter thing for me I think is to just make the pickup date and return date fields required. Thanks for your help, David. Turns out I just wasn't thinking correctly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the logic you've implemented, you will get the else only if the user selects 1, 2 or 3 AND pickup date - returned date <= 14. Is that what you tested?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is a select field with numbers as the options.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is the field type of customfield_18370?
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.