Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Setting default value in Input field in UI Page

jmcagod
Kilo Guru

Hello,

So we did some modifications in "employee_document_upload" UI Page, and we added "Active" field on the form.

What I'm trying to do is to set the Default value of Active = true. Because on the Employee document table, this field default is set to true - but when submitting it is was set to false.

I tried:

1.  <g:ui_reference name="active" value="${jvar_active}" displayvalue="true" table="sn_hr_ef_employee_document"/> (fig1) - its setting the default, but when submitting - it was still Active = false, and I don't want to use reference field.

2. input type="text" readonly="true" class="col-md-12 form-control" ng-model="active" id="active"  displayvalue="true"/> (does not the set default or display value)

3. using g:evaluate, no luck - not sure how to use this.

<!--NEW Added Field- Active - READ ONLY -->
<div class="row col-md-12">
<label for="active" dir="ltr" class="col-md-2 control-label">
<span id="active-label" class="label-text" data-html="false">${gs.getMessage('Active')}</span>
</label>
<div class="col-md-3 form-field input_controls">
<g:evaluate var="jvar_edm" object="true">
var gr = new GlideRecord("sn_hr_ef_employee_document");
gr.query();
gr;
</g:evaluate>
<j:set var="jvar_edm_active" value="${jvar_edm.getValue('active')}"/>

<!--<g:ui_input_field label="Active" name="active" readonly="true" size="25" value="${jvar_edm.getValue('active')}" displayvalue="${jvar_edm.getValue('active')}"/>-->
<!--<input type="text" readonly="true" class="col-md-12 form-control" ng-model="active" id="active" displayvalue="true"/>-->
<g:ui_reference name="active" value="${jvar_active}" displayvalue="true" table="sn_hr_ef_employee_document"/>
</div>

fig.1)

find_real_file.png

 

Hope anyone can help.

Thank you,

Jamie

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

I don't have this issue, when the form is submitted it defaults to active.

find_real_file.png

 

Have you checked the sn_hr_ef_employee_document table to ensure the default value for active is true?


find_real_file.png

 

The actual record creation process is just done through a http.put method through the table API.

find_real_file.png

However, the UI Page does explicitly set the document to active

find_real_file.png

 

If these OOB configurations are present, it would be worth validating you don't have any 'insert' business rule running.

 

View solution in original post

2 REPLIES 2

Kieran Anson
Kilo Patron

Hi,

I don't have this issue, when the form is submitted it defaults to active.

find_real_file.png

 

Have you checked the sn_hr_ef_employee_document table to ensure the default value for active is true?


find_real_file.png

 

The actual record creation process is just done through a http.put method through the table API.

find_real_file.png

However, the UI Page does explicitly set the document to active

find_real_file.png

 

If these OOB configurations are present, it would be worth validating you don't have any 'insert' business rule running.

 

Hi Keiran,

Thank you! the data.active = true in your screenshot was actually the reason why it was inactive. I have actually added another data.active on the script when I updated the UI page.

Thanks again! 

Jamie