Hi folks,
Within assets we have servers lumped into groups. We would like to be able to put a group name into a field and have it fill with all the servers in that group.
I current have this working using the following code:
def issue = Issues.getByKey('JTA-1')
def targets = issue.getCustomFieldValue("Change Targets")
def servers = []
targets.each { object ->
if (object.objectTypeId == 3158){
def iql = '"Patch Phase" = ' + object.getObjectKey()
Assets.search(iql).each { server ->
servers.add(server)
}
}
}
log.debug("Adding ${servers.size} servers to change target")
servers.each { server ->
log.debug("Adding ${server}")
issue.update {
setCustomFieldValue("Change Targets") {add (server)}
}
}
Unfortunately this is really slow as it does an update for each item, I figure there must be a way to set the custom field value to an array in one go, but i cannot figure it out.
Any ideas ?
Maybe I don't get it right, but for the desired behaviour you do not need to do Groovy magic at all.
You could have a "Group" Assets custom field which is selectable by the user and you could have your "Change targets" which also could be an Assets custom field. In the latter you can simply use the "Filter Assign Scope (AQL)" and refer to the "Group" custom field together with the "Assign strict" option.
We need the Jira linked to each individual server, not the group.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, that's the case if you use the "Filter Assign Scope" in the "Change targets" fields based on the "Group" field.
This will automatically put all server objects that belongs to the chosen group into that custom field.
But maybe I'm misunderstand what you mean with "linking the ticket to each server"
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.