GlideRecord - updateWithReferences(Object reason)

Updates a record and also inserts or updates any related records with the information provided.

Table 1. Parameters
Name Type Description
reason Object A string designating the reasons for the updates. The reason is displayed in the audit record.
Table 2. Returns
Type Description
String The sys_id for the record being updated.

If processing an incident where the Caller ID is set to reference sys_user record 'David Loo,' then the following code would update David Loo's user record. If processing an incident where there is no Caller ID specified, then the following code would create a new sys_user record with the provided information (first_name, last_name) and set the Caller ID value to the newly created sys_user record.

var inc = new GlideRecord('incident');
inc.get(inc_sys_id);  // Looking up an existing incident record where 'inc_sys_id' represents the sys_id of a incident record
inc.caller_id.first_name = 'John';
inc.caller_id.last_name = 'Doe';
inc.updateWithReferences();
}