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

Autopopulating fields in a form built in UI Pages

yundlu316
Kilo Guru

Hi, I'm creating a form in a UI Page and want to pre-populate some fields from sys_user.   The issue I run into is this error message: "The value of attribute "value" associated with an element type "input" must not contain the '<' character."

I've used the following script to pull the first_name field from sys_user:

<script>

<g:evaluate var="jvar_user_name">  

var gr = new GlideRecord('sys_user');  

gr.get('sys_id', gs.getUserID());  

gr.first_name.getHTMLValue();  

</g:evaluate>

</script>

Here's my HTML:

<table>

  <tr>

      <td><input type="text" id="first_name" name ="firstname" value="<g:no_escape>${jvar_user_name}</g:no_escape>"></input></td>

</tr>

</table>

Is there an alternate syntax to do this?

1 ACCEPTED SOLUTION

Stephen W_
Giga Guru

Why are you attempting to add "<g:no_escape>" within the value?  



Remove that tag, as there should be no need for that for anything you put into a text field.



If you absolutely need to add XML/HTML, consider using the innerHTML instead of value.


View solution in original post

6 REPLIES 6

Nam Nguyen
Tera Expert

Just wondering what are you trying to achieve by putting HTML content into the input value?


If it's just value, can it be done without the HTML?



<script>


<g:evaluate var="jvar_user_name">


var gr = new GlideRecord('sys_user');


gr.get('sys_id', gs.getUserID());


gr.first_name;


</g:evaluate>


</script>



Here's my HTML:


<table>


  <tr>


      <td><input type="text" id="first_name" name ="firstname" value="${jvar_user_name}"></input></td>


</tr>


</table>


HI Nam, you're correct, if I take out getHTMLValue I still get the field values, however it loses all of its formatting.   For example, without getHTMLValue for phone number returns +12025555555, but if getHTMLValue remains, then phone number returns as +1(202) 555-5555.



Thanks.