Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Java and Current User Email

  • 1.  Java and Current User Email

    SILVER CONTRIBUTOR
    Posted 19 days ago
    Does anyone know how to use Java to return the current logged in user's email (primary email address from his user record)

    We are needed to pass that parameter in CRM 365 and Resco....Resco I can only pull the login....which is the email.

    Thanks.

    ------------------------------
    Martin Doll
    Business Systems Analyst
    Ennis-Flint, Inc.
    Thomasville NC
    ------------------------------
    CRMUG Summit - Post


  • 2.  RE: Java and Current User Email

    GOLD CONTRIBUTOR
    Posted 16 days ago
    Hi,

    You should be able to retrieve this from the user's (systemuser) record using a retrieve with the new web API:

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/retrieverecord

    And the current user's ID will be available from the new global context: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility/getglobalcontext/usersettings

    Hope this helps!

    ------------------------------
    Aaron Hirshfield
    Sr. CRM Developer
    Foundation Medicine
    Needham MA
    ------------------------------

    CRMUG Summit - Post


  • 3.  RE: Java and Current User Email

    SILVER CONTRIBUTOR
    Posted 16 days ago
    Thanks Aaron.
    I was speaking more on the client side - java....where I have an html button and are passing parameters to a url.


    ------------------------------
    Martin Doll
    Business Systems Analyst
    Ennis-Flint, Inc.
    Thomasville NC
    ------------------------------

    CRMUG Summit - Post


  • 4.  RE: Java and Current User Email

    GOLD CONTRIBUTOR
    Posted 15 days ago
    Right, this is all client side code. I assumed you were talking about writing a web resource inside CRM? Are you imbedding some external page on your CRM form?

    If it's within CRM, you make a new javascript web resource with a function along the lines of:

    Xrm.WebApi.retrieveRecord("systemuser", Xrm.Utility.getGlobalContext().userSettings.userId, "?$select=emailaddress").then(
    function success(result) {
    // Call your URL here and pass result.emailaddress.
    },
    function (error) {
    console.log(error.message);
    // handle error conditions
    }
    );


    The links I posted have more detailed information.

    ------------------------------
    Aaron Hirshfield
    Sr. CRM Developer
    Foundation Medicine
    Needham MA
    ------------------------------

    CRMUG Summit - Post


If you've found this thread useful, dive deeper into User Group community content by role