Filter ui_reference in a UI Page

Michael Kaufman
Giga Guru

I have an Assignment Group and Assigned to fields on an UI Page. I want to filter the Assigned To list by "active=true^roles=itil" and the Assignment Group.

I don't know how to do this, and there isn't much documentation. Any ideas?

I tried adding "'QUERY:active=true^roles=itil" to the name, but that messes up the processing script. Also I can't figure out how to filter the users by the groups selected in this UI Page.

Here is my html:



<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<form action="ui_page_process.do">
   <input type="hidden" name="name" value="hp_planned_task_creator"/>
   <input type="hidden" id="cancelled" name="cancelled" value="false"/>
   <g:evaluate>
         var parent_task = '${sysparm_sysID}';
   </g:evaluate>
     <table>
           <tr>
                 <td nowrap="true">
                       <label>Assignment Group:</label>
                 </td>
                 <td>
                       <g:ui_reference name="assignment_group" id="assignment_group" table="sys_user_group" value="${sysparm_group_value}" displayvalue="${sysparm_group_displayvalue}"/>
                 </td>
           </tr>

           <tr>
                 <td nowrap="true">
                       <label>Assigned to:</label>
                 </td>
                 <td>
                       <g:ui_reference name="assigned_to"   id="assigned_to" table="sys_user"/>
                 </td>
           </tr>
           <tr>
                 <td nowrap="true">
                       <label>Time Card Active:</label>
                 </td>
                 <td>
                       <g:ui_checkbox name="timecard_active" value="${sysparm_timecard_active}"/>
                 </td>
           </tr>
           <tr>
                 <td nowrap="true">
                       ${gs.getMessage('Quantity')}:
                 </td>
                 <td>
                       <input name="task_quantity" id="task_quantity" value="1"/>
                 </td>
           </tr>
           <tr>
                 <td align="right"   colspan="2">
                       <g:dialog_buttons_ok_cancel ok="return true;" cancel="return onCancel();" />
                 </td>
           </tr>
     </table>
     <input type="hidden" name="parent_task" id="parent_task" value="${sysparm_sysID}"/>
</form>
</j:jelly>


1 ACCEPTED SOLUTION

Michael Kaufman
Giga Guru

I figured out how to filter the ui_reference field.



<g:ui_reference name="QUERY:active=true^roles=itil" id="assigned_to" table="sys_user" />


Then in the Processing Script, you reference that name field like this:



newTask.assigned_to = request.getParameter("QUERY:active=true^roles=itil");


Now I want to make this ui_reference field dependent on another ui_reference. For instance, I have an Assignment field and an Assigned To field. I want the assigned to dependent what the Assignment field is selected?

Is there a parameter with a ui_reference to make it dependent on another field?


View solution in original post

10 REPLIES 10

Hi Brent,


Did you checkout my comments, I guess a little session storage can come in handy here.


Let me know if you need more inputs.



Thanks,


Dhananjay


Hi Dhananjay,


Thanks for your post. I need some help with reference qualifier on UI page. I have not worked much with UI page. Hence not sure how to implement that. My requirement is depending on a particular field value, reference qualifier needs to be added.



First field is-


td>


          <g:ui_reference id="bus_service" label="Business Service" value="${jvar_serviceID}" name="QUERY:sys_class_nameINSTANCEOFcmdb_ci_service^ORsys_class_name=cmdb_ci_appl^ORsys_class_name=u_software" table="cmdb_ci" onchange="updateAssignmentGroups();"/>


      </td>



Second field is-


<td>


          <g:ui_reference id="symptomID" name="QUERY:u_type=incident" table="u_symptom" value="${jvar_symptomID}" onchange="updateAssignmentGroups();"/>


      </td>




I need to change Second field's reference qualifier to something like "QUERY:u_service="+${jvar_serviceID} .Is this possible to implement that.




Regards,


Purbali


Hi Purbali,


I would presume there is no dependency between first and second reference qualifier, so if that is the case you can implement just as you have mentioned.


But if your second reference qualifier is dependent on selection of value from First fields, then you can try using the suggestion I had given earlier.


So in your call to updateAssignmentGroups client script function you can set a session variable with current selected value.




<g:ui_reference name="symptomID" name="QUERY:JSCRIPT:SomeUtilClass.getSymptomRefQual();"   table="u_symptom" value="${jvar_symptomID}" onchange="javascript:updateAssignmentGroups(this.value);"/>




Your script class with look like




var SomeUtilClass = Class.create();


SomeUtilClass.getSymptomRefQual() {


var serviceID =       gs.getSession().getClientData('serviceID');


var refQual = 'u_service='+serviceID;


return refQual;


};




function updateAssignmentGroups(value){


  var ga = new GlideAjax('AjaxUtil');


    ga.addParam('sysparm_name','setSession');


    ga.addParam('sysparm_var','serviceID');


    ga.addParam('sysparm_var_value',value);


    ga.getXMLWait();


}



You can write a AjaxUtil which will set the session using gs.getSession().putClientData('serviceID',value);



Hope this helps!


Thanks Dhananjay for your input. I will try that out.



Regards,


Purbali


Sure! Let me know if it works or if you need further help.