Tuesday, March 15, 2016

Get Object Type Code Based on Entity Name in Javascript

Hi All,

Please find the Javascript to get Account Type Code.

function onload() {
    var getAccountCode = getobjecttypecode("account");
    alert(getAccountCode);
}

function getobjecttypecode(entityName) {
    try {
        var lookupService = new RemoteCommand("LookupService", "RetrieveTypeCode");
        lookupService.SetParameter("entityName", entityName);
        var result = lookupService.Execute();

        if (result.Success && typeof result.ReturnValue == "number") {
            return result.ReturnValue;
        }
        else {
            return null;
        }
    }
    catch (ex) {
        throw ex;
    }

}

No comments:

Post a Comment

How do I patch a Currency field value from a Canvas Power App to Dataverse?

  Introduction: In this blog, we will see how to patch a Currency field value from a Canvas PowerApps to Dataverse or MSCRM Implementation S...