- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2014 08:52 AM
Dear all,
I have been cracking my head for hours, looked through various discussion threads and am still getting absolutely nowhere with this - thus, any help on is more than appreciated
I'm currently working on a UI page which essentially resembles a form to edit a given record. It works like a charm except for the reference fields which I just can't get to pre-populate based on a given record.
The UI page's xml includes several reference fields, e.g. :
<g:ui_reference name="approved_by" id="approved_by" table="sys_user" show_lookup="true"/>
How would I go about populating this field from the client script, given that I have the reference record's sys_id? I have explored various options (just to give you some keywords of what I've looked into: g_form, setValue, setDisplayValue, getElementsByName, getElementById)
Many thanks in advance,
straightforward
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2014 09:07 AM
try this ...
gel('approved_by').value = sysID;
gel('sys_display.approved_by').value = displayValue;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2014 09:07 AM
try this ...
gel('approved_by').value = sysID;
gel('sys_display.approved_by').value = displayValue;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2014 02:07 AM
Thanks, you just made my day!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2014 09:41 AM
Hey Christoph,
One method I've used to avoid the UI page complexities for these types of things is to use a Record Producer. Normally a record producer is used to insert a new record, but you can simply add the below line to the producer script and it won't insert anything if you set the abort action:
// Query for the record you want to update
var gr = new GlideRecord('table_to_update');
gr.get(producer.selectedRecord);
// Set values based on the producer variables
gr.comments = producer.comments;
gr.update();
// Override the normal producer behavior to insert a record
current.setAbortAction(true);
The benefit of this is the following:
- You gain access to standard g_form client side functions
- Utilizes variables that are easy to work with
- You can still control basic form layout, look and feel
- You can have multiple client scripts named by functionality just like a catalog item
- You have access to UI Policies as well
Hope that helps!
Jared Healy