Filter the api response using Sysparm_query for nested JSONObject

Adithya Khurana
Tera Contributor

Hello,
Is there a way to filter the response using sysparm_query, i want the role to be itil & the provided user id.
I tried the below query but it doesn't work. could you please help.

role.display_value=itil^user.value=

b6b364e253131300e321ddeeff7b121b


Response :

{
"role": {
             "display_value": "knowledge_manager",
            "value": "f8bfbd02eb202100216a87b9d106fe92"
},
"user": {
              "display_value": "Problem Manager",
              "value": "d3dbbf173b331300ad3cc9bb34efc466"
}
},

 

 

 

shaunthesheep_0-1689941993776.png

 

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

@Adithya Khurana ,

No need to use role.display_value and user.value.

you can filter by 

sysparm_query: role=(sys_id of itil role)^user=(sys_id of user).

It's working as desired

View solution in original post

8 REPLIES 8

Community Alums
Not applicable

@Adithya Khurana ,

Is it a sys_user_has_role table ?

Community Alums
Not applicable

@Adithya Khurana ,

No need to use role.display_value and user.value.

you can filter by 

sysparm_query: role=(sys_id of itil role)^user=(sys_id of user).

It's working as desired

Adithya Khurana
Tera Contributor

yeah Thanks, so if i want to get the users having role itil.

1) I need to get the sys_id for itil role from sys_user_role table.
2) use that id in sys_user_has_role.

So, two API Call's has to made.  

Community Alums
Not applicable

@Adithya Khurana ,

Role field in sys_user_has_role is reference field so we need to pass SYS_ID.