web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Code to get the object Type Code in 2015 update 1

(0) ShareShare
ReportReport
Posted on by

I am using the following code to get the object type in ms dynamics CRM 2013 and 2015, in CRM 2015 Update 1 the code is not working?  

function GetObjectTypeCode(entityName)
{
/// <summary>
/// Gets the EntityTypeCode / ObjectTypeCode of a entity
/// </summary>
/// <param name="entityName" type="string">
/// Name of entity to return object type code of
/// </param>
/// <returns type="int" />
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;
}
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at
    RE: Code to get the object Type Code in 2015 update 1

    Hi Jishad,

    Have u tried this link?

    crmbusiness.wordpress.com/.../crm-20112013-javascript-to-get-the-object-type-code-of-an-entity

    Alsp post your error screenshot

    Regards,

    R.Rajkumar

    "Please mark my answer as verified if you found it helpful"

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Code to get the object Type Code in 2015 update 1

    This is not a supported method, better to shift to supported methods. You can write a metadata query.

    Check this: https://xrmservicetoolkit.codeplex.com/

    Thanks

  • Community Member Profile Picture
    on at
    RE: Code to get the object Type Code in 2015 update 1

    Hi Rajkumar,

    I tried it earlier, but it is not working. There is no error is showing, i put a debugger and see the code, once it is getting into the following line

    var lookupService = new RemoteCommand("LookupService","RetrieveTypeCode");

    it is return.

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at
    RE: Code to get the object Type Code in 2015 update 1

    Hi Jishad,

    Refer this thread for similar type of issue:

    community.dynamics.com/.../67401

    Hope this helps.

    Regards,

    R.Rajkumar

    "Please mark my answer as verified if you found it helpful"

  • Community Member Profile Picture
    on at
    RE: Code to get the object Type Code in 2015 update 1

    Hi HIMBAP,

    I gone through the link and downloaded the XrmServiceToolkit, what shall i do next?

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Code to get the object Type Code in 2015 update 1

    You can use just like other libraries and need to call it's method to get objectypecode. if you are looking for step by step instruction check this blog for how to step

    XrmServiceToolkit:alisharifiblog.wordpress.com/.../getting-related-record-lookup-fields-with-retrieve-multiple-using-the-rest-endpoint-with-javascript

    Thanks

  • Community Member Profile Picture
    on at
    RE: Code to get the object Type Code in 2015 update 1

    Hi HIMBAP,

    I didn't want Sdk.Rest rather than that i want the details why

    var lookupService = new RemoteCommand("LookupService","RetrieveTypeCode");

    this is not working and what is the update for this one.

    Also the code that you entered is not working, since the objcode is not assosiated with records, rather than it is assosiated with the Entity only.

  • Community Member Profile Picture
    on at
    RE: Code to get the object Type Code in 2015 update 1

    Hi Rajkumar,

    I just want to get the objtype code using the javascript only.

  • Suggested answer
    ScottDurow Profile Picture
    21 on at
    RE: Code to get the object Type Code in 2015 update 1

    RemoteCommand is not part of the support SDK and so I am not surprised it does not work anymore.

    You will need to make a call to the metadata to get the object type code - e.g. msdn.microsoft.com/.../gg594428.aspx

    If you want and easy and (again unsupported) technique - you can use:

    Mscrm.EntityPropUtil.EntityTypeName2CodeMap[entityName]

    Hope this helps,

    Scott

  • Verified answer
    Soma Shekar Profile Picture
    461 on at
    RE: Code to get the object Type Code in 2015 update 1

    Hi Jishad,

    In CRM 2015 updated rollup doesn't support the Remote command ,  you have to use supported methods only , 

    XrmServiceToolkit provides a method named as RetrieveEntityMetadata function , use this as follows

    var entityMetadata = XrmServiceToolkit.Soap.RetrieveEntityMetadata(["Entity"], "account", true);

    in the result you will get the Object type code of account entity 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans