updateRecord (CIF JavaScript API Reference)

Updates an entity record.

Syntax

microsoft-ciframework.updateRecord(entityLogicalName, id, data).then(successCallback, errorCallback);

Parameters

Name Type Required Description
entityLogicalName String Yes The entity logical name of the record you want to update. For example: "account".
id String Yes GUID of the entity record you want to update.
data String Yes

String containing key: value pairs, where key is the property of the entity and value is the value of the property you want to update.

See examples later in this topic to see how you can define the data string for the update scenario.

successCallback Function No

A function to call when a record is updated.

errorCallback Function No A function to call when the operation fails.

Return Value

On success, returns a promise containing a string with the updated attributes and their values.

Examples

This sample code updates an existing contact record with record ID = a8a19cdd-88df-e311-b8e5-6c3be5a8b200

//// define the data to update a record
var entityLogicalName = "contact";
var data = {
    "firstname": "Updated Sample",
    "lastname": "Contact",
    "fullname": "Updated Sample Contact",
    "emailaddress1": "contact@contoso.com",
    "jobtitle": "Sr. Marketing Manager",
    "telephone1": "555-0109",
    "description": "Updated values for this record were set programmatically."
}
// update contact record
var id = "b44d31ac-5fd1-e811-8158-000d3af97055";
var jsonData = JSON.stringify(data);
Microsoft.CIFramework.updateRecord(entityLogicalName,id,jsonData).then(
    function success (result) {
      res=JSON.parse(result);
          console.log("Contact updated with ID: " + res.id);
          //the record is updated
      },
      function (error) {
          console.log(error);
          //handle error conditions
      }
  );