g:ui_reference with dynamic query

grosch
Mega Expert

In my UI page I've got the following line:

<g:ui_reference name="service" table="cmdb_ci_service" query="u_state=Active"/>

I want that query field to be dynamic though.   Specifically, I want to run a GlideRecord() against the u_user_membership, pull out just the services for which I have a specifc role, and then pass that list of services to be the valid list for the above reference.

What would be even cooler is that if there is just one service for the person, then to display a label with that value instead of a reference picker.

1 ACCEPTED SOLUTION

manikorada
ServiceNow Employee
ServiceNow Employee

Scott,



You can do some thing like this :


<g:evaluate>


//do your glidequery here


//set a variable 'query' to the list of services


</g:evalaute>



<g:ui_reference name="service" table="cmdb_ci_service" query="{query}"/>


View solution in original post

2 REPLIES 2

manikorada
ServiceNow Employee
ServiceNow Employee

Scott,



You can do some thing like this :


<g:evaluate>


//do your glidequery here


//set a variable 'query' to the list of services


</g:evalaute>



<g:ui_reference name="service" table="cmdb_ci_service" query="{query}"/>


Thank you, that's perfect!