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 ?