Auto-Complete Reference Field Search for Multiple Fields

kesha
Kilo Contributor

I created a Service Catalog Item request and had a question regarding one of the requirements. The UI Macro associated to this request functions as required, however I need to have two values (Vendor Number and Alternate Vendor Number which are custom fields we created for the core_company table) auto-populate when the user is searching for the Company Name (as pictured in the screenshot below). The only way I was able to make this function was by adding an attribute to the core_company dictionary entry, but this is not our ideal option. Any feedback on how to implement this into my UI Macro would be greatly appreciated. I attached a copy of the UI Macro.

Attribute:

ref_ac_columns_search=true,ref_ac_order_by=name,ref_ac_columns=u_vendor_number;u_vendor_number_alternate,ref_auto_completer=AJAXTableCompleter

find_real_file.png

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

ui_reference is a ui macro having support for attributes .. completer,columns.



find_real_file.png


View solution in original post

15 REPLIES 15

Gurpreet07
Mega Sage

ui_reference is a ui macro having support for attributes .. completer,columns.



find_real_file.png


kesha
Kilo Contributor

That worked perfectly in my ui macro. Thanks!


Hi ,


Can you please help me out in updating my script to get more than two columns.




ui macro script:


-------------------



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">



<j:set var="jvar_list_data" value="${jvar_question_value}" />


  <j:set var="jvar_reference" value="core_company" />


  <j:set var="jvar_can_write" value="true" />


  <j:set var="jvar_control_name" value="${jvar_question_name}" />


  <j:set var="jvar_not_focused" value="true" />


      <j:set var="jvar_columns" value="u_id" />


  <g:evaluate>


        // make underscore.js available for server side scripting


        gs.include('getUserUtil');


        var query = new getCustomerUserUtil().getPrimaryUsers();


        query;


  </g:evaluate>


  <j:set var="jvar_ref_qual_elements" value="QUERY:${query}" />


  <g:macro_invoke macro="lightweight_glide_list_with_filter"


                                  list_data="${jvar_list_data}"


                                  reference="${jvar_reference}"


                                  can_write="${jvar_can_write}"


                                  control_name="${jvar_control_name}"


                                  not_focused="${jvar_not_focused}"


                                  filter_query="${query}"/>  


   


</j:jelly>



Thanks,


Revathy


Hi,


How can i implement this in my macro script.. can you please guide me. Here i wanted to have two columns while searching 1.name 2. id. where do i include the condition for that?



ui macro script:


-------------------



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">



<j:set var="jvar_list_data" value="${jvar_question_value}" />


  <j:set var="jvar_reference" value="core_company" />


  <j:set var="jvar_can_write" value="true" />


  <j:set var="jvar_control_name" value="${jvar_question_name}" />


  <j:set var="jvar_not_focused" value="true" />


      <j:set var="jvar_columns" value="u_id" />


  <g:evaluate>


        // make underscore.js available for server side scripting


        gs.include('getUserUtil');


        var query = new getCustomerUserUtil().getPrimaryUsers();


        query;


  </g:evaluate>


  <j:set var="jvar_ref_qual_elements" value="QUERY:${query}" />


  <g:macro_invoke macro="lightweight_glide_list_with_filter"


                                  list_data="${jvar_list_data}"


                                  reference="${jvar_reference}"


                                  can_write="${jvar_can_write}"


                                  control_name="${jvar_control_name}"


                                  not_focused="${jvar_not_focused}"


                                  filter_query="${query}"/>  


   


</j:jelly>



Thanks,


revathy


I am trying to get this right, but I am not able to.

 

There is a reference field on Incident form called Business Service which is referencing to cmdb_ci_service class.

 

I am using this attribute to show and search these columns : NAME, u_acronym

 

all_tables.text_index_translations=true,ref_ac_columns_search=true,ref_ac_order_by=name,ref_ac_columns=name;u_acronym,ref_auto_completer=AJAXTableCompleter

 

But I am not able to see the column u_acronym to search for and auto-complete is not showing this column as well. 

 

u_acronym is the custom field created on business service class and is of type String.