UI page dependent reference field

poornima2
Mega Expert

We do have client/matter number reference fields on a UI page. I am trying to set the filter for the matter field based on the client field selection. Is this possible? Thanks!

<g:ui_reference id="clientNum" name="clientNum" table="u_clients"   completer="AJAXTableCompleter" columns="u_client_name" order_by="name" onchange="xtest()"/>

<g:ui_reference id="matterNum" name="matterNum" table="u_matters"   completer="AJAXTableCompleter" columns="u_matter_name" order_by="name"/>

find_real_file.png

1 ACCEPTED SOLUTION

The following code worked.



HTML:


    Client Number        


    <g:ui_reference id="clientNum" name="clientNum" table="u_clients" query="active=true" onchange="setMatterFilter()"/>



      Matter Number        


      <g:ui_reference id="matterNum" name="matterNum" table="u_matters" />



Client script:


function setMatterFilter(){


      var CNSysId = gel('clientNum').value;


      var MNLookUp = gel('lookup.matterNum');


                  MNLookUp.setAttribute('onclick',"mousePositionSave(event); reflistOpen( 'matterNum', 'not', 'u_matters', '', 'false','QUERY:active=true',           'u_client_number=" + CNSysId+ "', '')");


}


View solution in original post

11 REPLIES 11

Hi Kalaiarasan,



Thank you. I will test this after each upgrade.


I have found that you also have to update the sys_display also if you would like the auto completer to also filter while typing.



So


gel('sys_display.matterNum').setAttribute('onfocus',"if (!this.ac) new AJAXReferenceCompleter(this, 'matterNum', '', 'QUERY:'u_client_number=" + CNSysId+ "', 'u_clients');


Yasin7
Kilo Contributor

Hi Drew ,



Please explain the code



gel('sys_display.matterNum').setAttribute('onfocus',"if (!this.ac) new AJAXReferenceCompleter(this, 'matterNum', '', 'QUERY:'u_client_number=" + CNSysId+ "', 'u_clients');



this.ac ,   AJAXReferenceCompleter - refer to


You do that to update the filter.   I got the code from the client side script when inspecting the page.   Not sure I can explain all that it does other than really what it already shows.


Hello Poornima,

i am trying ti achieve same functionality but facing issues.
i have exact same code.
filter is working but value is not getting selected on second field.

have you also faced same problem?

Thanks 


Neeraj