Hello,
I have an Assets object in which I want to update a date via Postfunction, I am testing HAPI to do this. I have been following this documentation https://docs.adaptavist.com/sr4js/latest/hapi/work-with-assets-insight
I am able to update normal text fields but I am not sure about the format to update a date field.
Correct way was:
Hey @Lara Lopez , tech lead for ScriptRunner here. Yep, you are correct. Give us a shout if you need anything else in HAPI Assets.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Jamie!
Loving HAPI! Specially for working with Assets (Insight)
It would be great if it had something to make it easier to get in Server/DC the key of an Insight object from a customfield to work with it.
The above question was related to this little script, as you see when I get the key of the Assets object from the custom field of the issue, I have to use regex to just pick the key, as it returns something like [ABE124 (ITASSET-123)] and I only need the info between the brackets.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lara...
Great to hear your feedback, thanks!
So, `getCustomFieldValue` will return the actual type of the custom field, in this case it is a List<ObjectBean>, or list of ObjectBeans.
You are calling toString on that, which is why you get the square brackets, and then `ABE124 (ITASSET-123)` is presumably the label and key.
I believe you always get a list from the Insight field, so you need to get the first object if present, then call the getObjectKey() method as shown here:
def issue = Issues.getByKey('JRA-1')
def insightObjects = issue.getCustomFieldValue('Affected Device')
def objectKey = insightObjects?.first()?.objectKey
// do something with objectKey
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.