I hope someone can help me; I have a little bit of a beginner question. How can i access an object and its variables/attributes after a successfull search. In log i get results so its working but iam not able to access or handle the result... I simply like to get the key, name and so on, within the .each but dont know how to do that.
def asset = Assets.search('objectType IN ("Users") AND Email = "test@test.at"').each {
return it.Key // this doesnt work
//log.debug(it) // log result
}
I suggest that you use ScriptRunner HAPI feature to simplify this approach. You can refer to the Working with Assets sections to get some ideas.
To use ScriptRunner's HAPI, you will need to upgrade your ScriptRunner plugin to the latest release, i.e. 8.8.1 or at least version 7.11.0.
I hope this helps to solver your question. :-)
Thank you and Kind regards,
Ram
Thank you all for your answers; for me this was the solution; i found it on the site linked by @Ram Kumar Aravindakshan _Adaptavist_
it.getString("Name")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you executing the script with ScriptRunner?
If so, then for the first look, you are trying this correctly. Can you try if
it.key
instead of
it.Key
works better?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your anwer; if i try it also in small letters i get the following message:
No such property: key for class: com.riadalabs.jira.plugins.insight.services.model.LegacyObjectBean Possible solutions: id
if i take it.id i get as i can see the process id; i coded the follwing function that is still working; but i think there is a much better way; getId() only works if i define the empty result variable before:
def returndevice(devicename) {
def result = ""
Assets.search('"Devices" IN ("'+ devicename +'") ORDER BY Start ASC').each {
result = it.getId()
}
return result
}
return returndevice
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.