GlideRecord - update(Object reason)

Updates the GlideRecord with any changes that have been made. If the record does not exist, it is inserted.

Table 1. Parameters
Name Type Description
reason Object A string designating the reason for the update. The reason is displayed in the audit record.
Table 2. Returns
Type Description
String Unique id of the new or update record. Returns null if the update fails.

Scoped equivalent

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

  var gr = new GlideRecord('task_ci');
gr.addQuery();
gr.query();
var count = gr.getRowCount();
if (count > 0) {
   var allocation = parseInt(10000 / count) / 100;
   while (gr.next()) {
      gr.u_allocation = allocation;
      gr.update();
   }
}