The CreatorCon Call for Content is officially open! Get started here.

How to add Reference field in UI page

Gazal Varshney2
Tera Contributor

Hi,

 

I have a requirement to add Assignment group field whenever I click on create incident option from form context menu. IT displays a UI page. I am able to show the field but could not get the options like we get for assignment group field in normal forms (reference to Group table). I have written the below codeby which I am able to fetch the assignment group from the record but not getting all the options of group table:

 

<j:if test="${sysparm_action == 'incident'}">
<div class="row form-section">
<div class="col-sm-3 section-title-top">${gs.getMessage('Assignment Group')}</div>
<div class="col-sm-5">
<g:evaluate var="jvar_property">
var grList = GlideChoiceList.getChoiceList('sys_user_group','name');
</g:evaluate>
<select id="group" class="form-control" name="group" aria-label="group">
<g2:options choiceList="$[grList]" choiceValue="$[secInc.assignment_group.name.toString()]" />
</select>
</div>
</div>
</j:if>

 

What approch should I follow to get the record of sys_use_group table as a reference/option in my field?

 

thanks,

Gazal Varshney

1 ACCEPTED SOLUTION

 <g:macro type="text" name="REQUIRED" label="REQUIRED" value="" onkeyup="" onchange="onChange('${jvar_name}');" onclick_label="" mandatory="false" size="" style="" readonly="false" maxlength=""/>

View solution in original post

11 REPLIES 11

Gaurav Shirsat
Mega Sage

Hi Gazal

<g:ui_reference   id="mainrecord" table="u_childtable"   completer="AJAXTableCompleter" "id" onchange="ValueChanged()" />

https://community.servicenow.com/community?id=community_question&sys_id=37008721db98dbc01dcaf3231f96...

Please Mark Correct and Helpful

Thanks and Regards

Gaurav Shirsat

ricker
Tera Guru

It sounds like your field type is string or something?. What is the field type?  It should be Reference and point at the 'sys_user_group' table.  When setting the value of the field in your script you would use the sys_id.

 ohhh I think I see..you're using the normal Assignment Group field...you need to set the value to the sys_id.

I think it should look like this instead.

<g2:options choiceList="$[grList]" choiceValue="$[secInc.assignment_group.sys_id]" />