locked
Access User Entity Attributes through JavaScript RRS feed

  • Question

  • How can I access the user's primary email field via JavaScript?  The following code sample works fine to get the user's full name, but I cannot figure out how to access other fields on the user entity.

    Consider the .FullName field on the user entity.  If you look up the name, the name is fullname.  If you used that in the JQuery call, it would fail.  You also cannot use the display name because it has a space in it.  So how do you look up the name of the other fields?

    There is a field named "Primary Email Address" with a name of "internalemailaddress".  I tried both and neither work.  So how do we look these up?  If it is not the display name, not the actual name, then how do we know what name to use?  I cannot even find a list on MSDN but I suspect it is there somewhere.

    Any suggestions, links, etc. are much appreciated. 

    function RetrieveUser(id) {
     SDK.JQuery.retrieveRecord(
         id,
         "SystemUser",
         null, null,
         function (systemuser) {
             alert("Retrieved the user \"" + systemuser.FullName+ "\". This account was created on : \"" + systemuser.CreatedOn + "\".");
             alert(systemuser.InternalEmailAddress);
         },
         errorHandler
       );
    }
    


    Jon Gregory Rothlander

    Tuesday, February 11, 2014 3:36 PM

Answers

  • Hi,

    you can do advance find for the required entity and download fetch xml for the given entity. you will have the schema name, but if you want to have schema name and display name of each attribute then you need to download  CRM SDK. which has each system entity details. you can download from the below given link.

    http://www.microsoft.com/en-in/download/details.aspx?id=24004

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Thanks & regards

    Subhash


    Wednesday, February 12, 2014 8:08 AM
  • Hi,

    To check schema name you can simply navigate to Settings->Customizations->Customize System->Entities, you should be able to see schema name for entities and if you will select particular entity and field you will be able to see schema name for fields as well.

    you can also check using https://CRM_Server/XRMServices/2011/OrganizationData.svc/

    (Settings->Customizations->Customize System->Developer Resources->Organization Data Service)


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Wednesday, February 12, 2014 12:54 PM
    Moderator

All replies

  • You need to use the Schema Names of the fields with oData/REST

    So something this:

    SDK.JQuery.retrieveRecord(
        id,
        'SystemUser',
        "FullName,InternalEMailAddress",
        null,
        function (result) {
            var FullName = result.FullName;
            var InternalEMailAddress = result.InternalEMailAddress;
        },
        function (error) {
             alert(error.message);
        },
        true
    );


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Tuesday, February 11, 2014 4:41 PM
    Moderator
  • Thanks for the reply Jason and the sample. 

    How do I look those up?  I can Google it and eventually find a reference, but how can I just go in and look at a list of all of those schema names?  Is there a reference an XML file or some way to see them?  Maybe hitting the service in IE and getting a WSDL or something?

    Thanks,

    Jon 


    Jon Gregory Rothlander

    Tuesday, February 11, 2014 9:42 PM
  • Hi,

    you can do advance find for the required entity and download fetch xml for the given entity. you will have the schema name, but if you want to have schema name and display name of each attribute then you need to download  CRM SDK. which has each system entity details. you can download from the below given link.

    http://www.microsoft.com/en-in/download/details.aspx?id=24004

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Thanks & regards

    Subhash


    Wednesday, February 12, 2014 8:08 AM
  • Hi,

    To check schema name you can simply navigate to Settings->Customizations->Customize System->Entities, you should be able to see schema name for entities and if you will select particular entity and field you will be able to see schema name for fields as well.

    you can also check using https://CRM_Server/XRMServices/2011/OrganizationData.svc/

    (Settings->Customizations->Customize System->Developer Resources->Organization Data Service)


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Wednesday, February 12, 2014 12:54 PM
    Moderator