"Default Value" attribute on <g:ui_reference_multi ??

Phuc Sinh
Tera Contributor

Currently, I want to set a default value for a <g:ui_reference_multi tag in UI Macro. I want to set a default group for a reference field, reference to a group table. I tried many ways, adding attribute "value" "display_value", "displayvalue" , "default" but can not set value for this field.


Does the <g:ui_reference_multi in a UI Macro support an attribute for specifying a default value or are there any other ways to achieve this? Thank you! 

I tried to do the same in this article but can not achieve this
https://www.servicenow.com/community/developer-forum/quot-default-value-quot-attribute-on-lt-g-ui-re...

Here is my code:

<g:ui_reference_multi name="watchlist_group_reference_general_other_request" value="7724f897478d311478efca49116d43f8" table="sys_user_group" display_value="name" id="watchlist_group_reference_general_other_request" query="u_applicationsLIKE4378255adbb98d50d101a82dd3961966"/>




5 REPLIES 5

Community Alums
Not applicable

Hi @Phuc Sinh ,

 

Please try the below code once-

<g:ui_reference_multi 
    name="watchlist_group_reference_general_other_request" 
    value="7724f897478d311478efca49116d43f8" 
    table="sys_user_group" 
    display_value="AL5 GHQ Support Group" 
    id="watchlist_group_reference_general_other_request" 
    query="u_applicationsLIKE4378255adbb98d50d101a82dd3961966"/>

Client script-

function onLoad() {
    var multiRefField = g_form.getControl('watchlist_group_reference_general_other_request');
    if (multiRefField) {
        // Default value (sys_id of the group)
        var defaultValue = '7724f897478d311478efca49116d43f8';
        // Display value (name of the group)
        var displayValue = 'AL5 GHQ Support Group';
        g_form.setValue('watchlist_group_reference_general_other_request', defaultValue, displayValue);
    }
}

 

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks & Regards,

Sanjay Kumar