Uredi

Deli z drugimi prek


retrieveRecord (JavaScript API Reference) for Dynamics 365 Channel Integration Framework 1.0

Retrieves an entity record.

Syntax

Microsoft.CIFramework.retrieveRecord(entityLogicalName, id, options).then(successCallback, errorCallback);

Parameters

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

OData system query options, $select and $expand, to retrieve your data.

  • Use the $select system query option to limit the properties returned by including a comma-separated list of property names. This is an important performance best practice. If properties aren’t specified using $select, all properties will be returned.
  • Use the $expand system query option to control what data from related entities is returned. If you just include the name of the navigation property, you’ll receive all the properties for related records. You can limit the properties returned for related records using the $select system query option in parentheses after the navigation property name. Use this for both single-valued and collection-valued navigation properties.

You specify the query options starting with ?. You can also specify multiple query options by using & to separate the query options. For example:

?$select=name&$expand=primarycontactid($select=contactid,fullname)
successCallback Function No

A function to call when a record is retrieved.

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

Return Value

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

Examples

This sample code retrieves the name and phone number of a contact record with ID = a8a19cdd-88df-e311-b8e5-6c3be5a8b200.

// retrieve contact record
var id = "b44d31ac-5fd1-e811-8158-000d3af97055";
var entityLogicalName = "contact";
Microsoft.CIFramework.retrieveRecord(entityLogicalName, id, "?$select=fullname,telephone1").then(
    function success(result) {
      res=JSON.parse(result);
        console.log(`Retrieved values: Full Name: ${res.fullname}, Telephone Number: ${res.telephone1}`);
        // perform operations on record retrieval
    },
    function (error) {
        console.log(error.message);
        // handle error conditions
    }
);