locked
getOrgUniqueName() returning a GUID value? RRS feed

Answers

  • I don't believe there is any supported way to get the friendly name. If you can find an example of where CRM gets the friendly name using JavaScript for some alert etc then we could possibly see how they're doing it...

    Just to clarify, you want the Org name that is displayed in the top right corner of your screen, below your user name? If this is the case, then you can literally just get that value using JavaScript. From a form you can use this:

    var orgName = window.parent.document.getElementById('lblOrgName').innerHTML;

    Though this is a pretty bad way to do it, as they could remove the org name or change the ID at any time with a new rollup.

    That code may work from a grid view or ribbon, though I have only tested from Form OnLoad.

    Hope it helps

    Paul

    • Marked as answer by point_blank Tuesday, February 26, 2013 9:15 AM
    Tuesday, February 26, 2013 6:17 AM

All replies

  • Hi,

    http://hodgin.ca/2012/04/09/microsoft-dynamics-crm-2011-javascript-development-reference/


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay

    Tuesday, February 26, 2013 3:58 AM
  • I don't believe there is any supported way to get the friendly name. If you can find an example of where CRM gets the friendly name using JavaScript for some alert etc then we could possibly see how they're doing it...

    Just to clarify, you want the Org name that is displayed in the top right corner of your screen, below your user name? If this is the case, then you can literally just get that value using JavaScript. From a form you can use this:

    var orgName = window.parent.document.getElementById('lblOrgName').innerHTML;

    Though this is a pretty bad way to do it, as they could remove the org name or change the ID at any time with a new rollup.

    That code may work from a grid view or ribbon, though I have only tested from Form OnLoad.

    Hope it helps

    Paul

    • Marked as answer by point_blank Tuesday, February 26, 2013 9:15 AM
    Tuesday, February 26, 2013 6:17 AM
  • Hi..

    This is the code for getting the Orgname rethar than the GUID of Org. I tried it and got the Orgname. Hope it wil work for you.

    function org(){
    var i=Xrm.Page.context.getOrgUniqueName();
    alert(i);
    }


    Prudveen D

    • Proposed as answer by Prudween Tuesday, February 26, 2013 6:23 AM
    Tuesday, February 26, 2013 6:23 AM
  • Hi..

    This is the code for getting the Orgname rethar than the GUID of Org. I tried it and got the Orgname. Hope it wil work for you.

    function org(){
    var i=Xrm.Page.context.getOrgUniqueName();
    alert(i);
    }


    Prudveen D

    • Proposed as answer by Prudween Tuesday, February 26, 2013 6:29 AM
    Tuesday, February 26, 2013 6:29 AM
  • Tried this awhile ago, but it still returned the GUID value of the org.
    Tuesday, February 26, 2013 9:03 AM
  • But it works fine for me and displaying the organisation name in the alert box.

    Just add "Xrm.Page" before  "context.getOrgUniqueName" as i mentioned in previous post


    Prudveen D

    Tuesday, February 26, 2013 9:08 AM
  • Thanks Paul,

    your code worked, this is the unsupported way of doing it, but it does the job!

    However, if you notice in the MSDN Library (http://msdn.microsoft.com/en-us/library/d7d0b052-abca-4f81-9b86-0b9dc5e62a66#BKMK_getOrgUniqueName ) 

    the example written there was the "friendly name".



    • Edited by point_blank Tuesday, February 26, 2013 9:55 AM
    Tuesday, February 26, 2013 9:15 AM
  • Let me explain, because CRM Online does things a little bit differently to on-premise.

    The value returned by context.getOrgUniqueName() is the unique database name, which means no other org on the server can share the same name. For on-premise deployments, this is usually just the same as the Display Name (or friendly name) without the spaces. The unique name is also what you would see in the url when accessing that CRM org.

    For CRM Online however, the Unique Database Name would be set to something completely different than the actual org display name (sometimes something like 'crm5org04326' or like in your case a guid). The url still has the 'no space' version of the org name which is what can sometimes be confusing when trying to find the org name for CRM online.

    If you go into Customizations -> Developer Resources however, you can see the actual Organization Unique Name. This is what will always be returned when using getOrgUniqueName().

    In the SDK example, you can see the result has no spaces, so it is correct that it is getting the unique name, and not the friendly name (display name).

    Hope that explains things and makes it a bit clearer.

    Paul


    Tuesday, February 26, 2013 9:27 AM
  • Try with this.

    function org(){
    var i=Xrm.Page.context.getOrgUniqueName();
    alert(i);
    }

    Its worked for me.

    Tuesday, February 26, 2013 9:32 AM
  • thanks for enlightening me regarding this issue.

    Issue solved. :)


    • Edited by point_blank Tuesday, February 26, 2013 9:57 AM
    Tuesday, February 26, 2013 9:56 AM