Michael Philip's Blog

Writing about MS Tech with strong focus on Azure & CRM

MS CRM 2011 – Get Any Entity Object Type Code By Entity Name Using Java Script

Leave a comment

BriefThe CRM contains built in web service called “lookup Service ” which can be called through Java Script, its takes the “entity name” as a parameter and returns its object type code


function getObjectTypeCodeByName(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 (e){

alert(“Error while getting ETC by Name – ” + e.description);




Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s