UI Page: Set reference fields

Jake Sadler
Kilo Sage

How do I set the a reference field value in a ui page?

I currently have this:

HTML:

 

<g:ui_reference name="assigned_to" id="assigned_to" table="sys_user" query="active=true" completer="AJAXReferenceCompleter" ng-model="user" mandatory="true"/>
 
Client script:

function setRef(field,value){
gel('sys_display.'+field).value = value;
}
 
Does anyone know how to set the other attribute values like lookup and the actual value?
1 ACCEPTED SOLUTION

I don't think there is any official documentation for it. This is what is known to me:

 

  • id – unique id for the input field
  • name – unique name for the input field (should be the same as id in most cases)
  • value – (optional) sys_id of the record selected by default
  • displayvalue – (optional) display value of the record selected by default
  • table – name of the table to query from
  • query – encoded query string to pre-filter the list (i.e. a reference qualifier)
  • completer – AJAXReferenceCompleter (default) or AJAXTableCompleter
  • columns – a semicolon-separated list of fields to display in the dropdown (only works with AJAXTableCompleter)
  • onChange – client-side code to execute when the value changes

View solution in original post

5 REPLIES 5

Slava Savitsky
Giga Sage

You can use value and displayvalue attributes to prepopulate your reference field:

 

<g:ui_reference name="assigned_to" id="assigned_to" table="sys_user" query="active=true" value="62826bf03710200044e0bfc8bcbe5df1" displayvalue="Abel Tuter" />

 

From a client script, you can access the values as follows:

 

var user_id = $('assigned_to').value;				// grab the sys_id
var user_name = $('sys_display.assigned_to').value;	// grab the display value

 

Or change them like this:

 

$('assigned_to').value = '46d44a23a9fe19810012d100cca80666';
$('sys_display.assigned_to').value = 'Beth Anglin';

 

What other attributes are you looking for?

 

Hi,

 

What other attributes are there for the ui_reference fields. Are they documented somehwere?

 

 

I don't think there is any official documentation for it. This is what is known to me:

 

  • id – unique id for the input field
  • name – unique name for the input field (should be the same as id in most cases)
  • value – (optional) sys_id of the record selected by default
  • displayvalue – (optional) display value of the record selected by default
  • table – name of the table to query from
  • query – encoded query string to pre-filter the list (i.e. a reference qualifier)
  • completer – AJAXReferenceCompleter (default) or AJAXTableCompleter
  • columns – a semicolon-separated list of fields to display in the dropdown (only works with AJAXTableCompleter)
  • onChange – client-side code to execute when the value changes

Hi,

 

Do you know how I can allow users to search for records using different fields?

 

For instance, if we have a <g:ui_reference> for table incident, how would users be able to search for a specific incident by number (should be the default seach field) but also by caller's name for example? Is that possible?

 

Thank you