When adding groovy script to my post functions I got the problem that versions were created and visible but not usable by creating a issues. This is only possible after Jira reboot. The same problem occur when I change the assigned person, some value sticks or something (which is solved after reindex).
How can I solve this problem? The createVersion is a real problem.....
Behaviours comes with a "getRequestTypeName()" method that you can call.
Armed with that, you can convert that script to something quite simple:
Map validComponentNamesByRequestType = [
"Sales": ["Purchase", "Return"],
]
if (!requestTypeName) {
//no requestTypeName is available at this time (also happens when creating issues from Jira instead of the portal
return
}
def validComponentNames = validComponentNamesByRequestType[requestTypeName]
def validComponent = issueContext.projectObject.components.findAll { it.name in validComponentNames }
getFieldById("components").setFieldOptions(validComponent)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, @PD Sheehan sorry to bother you. How can I not show these components in the Tech Support request type? Right now it is working fine with Sales where I can see only components that I add in the script, but is there a way that those components are not shown in any other request type, like Tech Support. In Tech Support and another request type, I can see "Purchase" and "Return" too. Right now in Tech Support and other request types, I can see all components, but I don't those components display there. Is there any way that any components display in Sales request type, those components should not display in any other request type?
Thank you for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to confirm:
Sales Request Type => only show "Purchase" and "Return" component in the list
All other request type => Hide "Purchase" and "Return" components from the list
You could just add all your other request types here:
Map validComponentNamesByRequestType = [
"Sales": ["Purchase", "Return"],
"Tech Support": ["ComponentA", "ComponentB", ...],
...
]
Or if you don't want to have to update this script each time you add components or request tyes, you can have something like this:
Map exclusiveComponentByRequestType = [
"Sales": ["Purchase", "Return"],
]
if (!requestTypeName) {
//no requestTypeName is available at this time (also happens when creating issues from Jira instead of the portal
return
}
def validComponents = issueContext.projectObject.components
if (exclusiveComponentByRequestType.containsKey(requestTypeName)) {
//this is the same as earlier script version. Just with different variable names
def validComponentNames = exclusiveComponentByRequestType[requestTypeName]
validComponents = validComponents.findAll { it.name in validComponentNames }
} else {
//for the case where the request type is not in the exclusionlist, we look at each request types that have exclusions and we remove those items from the valid list
exclusiveComponentByRequestType.each{rtName, componentNames->
if(rtName != requestTypeName){
validComponents.removeAll { it.name in componentNames }
}
}
}
getFieldById("components").setFieldOptions(validComponents)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much @PD Sheehan, I tried the first method by mapping other components with other request types and it didn't work. I just realized I didn't add those request type I Mapping list, I had just Sales one.
Your second script would work better for me. Thank you again for helping. have a nice weekend.
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.