GlideElement - toString()

Converts the field's value to a string.

Table 1. Parameters
Name Type Description
None
Table 2. Returns
Type Description
String The field's value as a string.

Scoped equivalent

To use the toString() method in a scoped application, use the corresponding scoped method: Scoped GlideElement - toString().

doit();
 
function doit() { 
 
  var gr = new GlideRecord('sys_user');
  gr.query();
  while (gr.next()) {
    if ((gr.first_name.toString().length != gr.first_name.toString().trim().length) || (gr.last_name.toString().length 
         != gr.last_name.toString().trim().length)) {
      gr.first_name = gr.first_name.toString().trim();
      gr.last_name = gr.last_name.toString().trim();
      gr.autoSysFields(false);
      gr.update();
    }
  }
 
}