Get the current record ID using JavaScript in D365 CE

In this blog, we will learn how to get the GUID of record and logical name of the entity(table) using JavaScript in D365 CE(CRM).

Syntax to get the GUID:

var recordId = formContext.data.entity.getId();

Syntax to get the Entity Name:

var entityName = formContext.data.entity.getEntityName();

Code:

var formCustomizations = {
    getRecordDetail: function (executionContext) {
        var formContext = executionContext.getFormContext();
        var recordId = formContext.data.entity.getId();
        var entityName = formContext.data.entity.getEntityName();
        alert(`Record GUID: ${recordId} and Entity Name: ${entityName}`);
    }
}

Result:

Leave a Reply

Your email address will not be published. Required fields are marked *