Retrieving an attribute value from an Assets field
Asked by Dirk Ronsmans:

Hi,

So I have some object with a "group" attribute.

I'm trying to retrieve (thru automation on **Datacenter**) the value of this group attribute to store it in a (multi) group picker.

Right now when I Log the {{customfield_xxxx}} value it does return my object label and key like "Test (Ci-123)" however trying to get an attribute value never seems to output anything.

My attribute name is "User Group" and i've tried

* {{customfield_xxxx.User Group}}
* {{customfield_xxxx.\[User Group\]}}
* {{issue.customfield_xxxx.User Group}}
* {{issue.customfield_xxxx.\[User Group\]}}

but the output remains empty.

It seems that on Cloud i can get some more details but on DC I just can't seem to find the syntax.

Anybody got an idea?


Answers:
author: OMAR MOHAMED AHMED MOHAMED FATHY
body: this also can be useful <https://docs.adaptavist.com/sr4js/latest/integrations/automation-for-jira/lookup-asset-insight-object>


author: OMAR MOHAMED AHMED MOHAMED FATHY
body: try {{issue.customfield_xxxx.attributes.User Group}}


author: Mauricio Heberle
body: You could try for example creating a var with the value  

issue.custom_field.user group  

store it and send it to the other field you want.

comments: author: Dirk Ronsmans
body: Hey [@Mauricio Heberle](/t5/user/viewprofilepage/user-id/4973359) ,

That's a possibility, the problem is that getting the value of the field (meaning the attribute of the Asset object on the Asset field) always returns blank.


author: Mauricio Heberle
body: Even if the group attribute is filled? I believe it should return the group id thats added in the object attribute


author: Wouter van den Berg
body: Hi [@Dirk Ronsmans](/t5/user/viewprofilepage/user-id/124602)

I am not sure if you have tried {{customfield_xxxx"User Group"}}.

Can you share a screenshot of the User Group attributes. Assuming it's not a reference towards an Group object type.

comments: author: Dirk Ronsmans
body: I had not tried that syntax yet, but unfortunately it gives the same result.

Just a blank output.

This is my current object definition.

![2023-09-11 11_41_24-Assets - Jira ServiceDesk - TEST.png](https://community.atlassian.com/t5/image/serverpage/image-id/279810iEA0ACA8A43B62C84/image-size/large?v=v2&px=999 "2023-09-11 11_41_24-Assets - Jira ServiceDesk - TEST.png")


author: Wouter van den Berg
body: Hi [@Dirk Ronsmans](/t5/user/viewprofilepage/user-id/124602)  

Within DC it looks like the User Group is actually a reference to the actual groups a user is a member of. In Cloud you can use the Group information but it's not Automatically added.   

However, in this case you can use the IF/ELSE statement in Automation with a check if a user is part of a group. Unless somebody knows how the Group information can be retrieved within a custom field that is referencing object information that is referencing the groups in Jira.   

![Screenshot 2023-09-11 at 12.48.22.png](https://community.atlassian.com/t5/image/serverpage/image-id/279820i32796BF12DB0AFFF/image-size/large?v=v2&px=999 "Screenshot 2023-09-11 at 12.48.22.png")  

In my case (in Coud) I can reference that customfield by the previous example I gave.   


author: Dirk Ronsmans
body: Well it's an Asset so the "Group" type attribute just links to all available Groups in the group management. Nothing to do with whether a user is member of it or not.

I guess we just have different use cases.

For me I want to get the value of the "Group" attribute and set it on a multi group picker field on an issue. Meaning if you select the Asset object on the issue it will fill the group picker on the issue with the same value.

Guess I'll have to switch to good old Scriptrunner for this one


author: Wouter van den Berg
body: So you are saying that the Group is not pre-filed in the Object itself and therefore the same as with Cloud (not linked to the actual groups)?

![Screenshot 2023-09-11 at 13.00.36.png](https://community.atlassian.com/t5/image/serverpage/image-id/279832i8D63647944BAAE96/image-size/large?v=v2&px=999 "Screenshot 2023-09-11 at 13.00.36.png")

![Screenshot 2023-09-11 at 13.00.49.png](https://community.atlassian.com/t5/image/serverpage/image-id/279833iF842F122661CBC2B/image-size/large?v=v2&px=999 "Screenshot 2023-09-11 at 13.00.49.png")

If that's the same as with Cloud (a multigroup picker) than my reference should work but just needs the correct naming. Your object should then look like this (with no pre-filled group).   

![Screenshot 2023-09-11 at 13.04.23.png](https://community.atlassian.com/t5/image/serverpage/image-id/279834i0C4110E414746170/image-size/large?v=v2&px=999 "Screenshot 2023-09-11 at 13.04.23.png")  

If so. If I want to see the Groups within a customfield value I use {{customfield_xxxx"User Group"}}. Let me know if you see a value pre-populated or not. If you do than you will need a different approach (with or without SR).


author: Dirk Ronsmans
body: We do pre-populate the value in Assets.

e.g.

We have a group in Assets called Service Desk, the "User Group" Attribute is maybe "SD_L1"

SD_L1 is an actual Jira group with Jira Users in it.

On an Incident/Issue I select "Service Desk" from my Assets custom field and I want a different custom field (which is a group picker field) on the same issue to get the value SD_L1 (based on the value we retrieve from Assets)

Problem now is that I can't seem to get the SD_L1 value from the Assets object if I run an automation on the issue. It's always blank.

Hopefully that makes it more clear?


author: Wouter van den Berg
body: Correct me if I am wrong but you have two Custom Fields:

1. The Asset object customfield
2. Group picker customfield

If you want to copy the value of the Asset custom field to a Group picker custom field then you need to create a variable and catch {{Assetcustomfield_xxx"User Group"}} and then Edit Issue, Customfield Group picker.   

Having a customfield that's not an asset object custom field does not allow for directly injecting asset information. Hope this makes sense.

If that Group picker is an Asset Object field then the previous suggestion should work and since it doesn't I am assuming it's not a Asset custom field.   

Let me know.


Tags: assets

data-center

server