GlideRecord - getLabel()

Retrieves the field's label.

Table 1. Parameters
Name Type Description
None
Table 2. Returns
Type Description
String Field's label

Scoped equivalent

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

template.print("Summary of Requested items:\n");  
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sysapproval);
gr.query();
while(gr.next()) {
    var nicePrice = gr.price.toString();
    if (nicePrice != '') {
        nicePrice = parseFloat(nicePrice);
        nicePrice = nicePrice.toFixed(2);
    }
    template.print(gr.number + ":  " + gr.quantity + " X " + gr.cat_item.getDisplayValue() 
                     + " at $" + nicePrice + " each \n");
    template.print("    Options:\n");
    for (key in gr.variables) {
      var v = gr.variables[key];
      if(v.getGlideObject().getQuestion().getLabel() != '') {
         template.space(4);
         template.print('     ' +  v.getGlideObject().getQuestion().getLabel() + " = " 
                     + v.getDisplayValue() + "\n");  
      }
    }
}