Get ObjectTypeCode in CRM 2011 using Jscript

Posted: October 2, 2012 in CRM 2011, Jscripts

Using Jscript

var entityObjectTypeCode = Xrm.Page.context.getQueryStringParameters().etc

If you want to pass the entity name and get the objecttypecode then you can probably use the below code

function GetObjectTypeCode(entityName) {
    var lookupService = new RemoteCommand("LookupService", "RetrieveTypeCode");
    // pass the entityschema name
    lookupService.SetParameter("entityName", entityName);
    var result = lookupService.Execute();
    if (result.Success && typeof result.ReturnValue == "number") {
        return result.ReturnValue;
    else {
        return null;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s