updateRecordFields()
The updateRecordFields() function (server-side) updates specific fields on a record type without saving the record. Because the record isn't saved, user-event scripts won't be triggered when these updates are made.
Syntax
Use this syntax for the updateRecordFields() function:
updateRecordFields({
type: string,
id: string | number,
fields: {
fieldId1: 'value1',
fieldId2: 'value2',
// Additional fields
},
sourcing: true | false
}).done(callback)
.fail(callback);
Return Value
The updateRecordFields() function returns a promise that resolves to an object. The returned objects contains the ID of the record for which you updated fields.
{ id: string }
Parameters
All parameters are required, except sourcing.
The updateRecordFields() function accepts an object as a parameter. The object includes the following properties:
-
type- Specifies the record type you want to update, such asinventoryitemorcustomer. -
id- Specifies the internal ID of the record to update. -
fields(object) - Defines the fields to update and their new values. -
sourcing- Iftrue, this property refreshes the values of sourced fields associated with fields you have set. This property isfalseby default. Because this property may impact script performance, use it only when necessary.
Examples
The following examples show how to use the updateRecordFields() function.
Updating Record Fields
This example updates two fields on an inventory item.
updateRecordFields({
type: 'inventoryitem',
id: '1300',
fields: {
purchasedescription: 'Desk A1000 Series C - New',
stockdescription: 'Desk A1000 Series C'
},
sourcing: true
}).done(function(data) {
console.log('Success', data);
}).fail(function(data) {
console.log('Fail', data);
});