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)

How to get Organization url or discovery url in plugin

(0) ShareShare
ReportReport
Posted on by

Is there a way to get either discovery url or organisation url in plugin. 
I know i can get organisation name/id. But I need complete url so that i can differentiate between dev/ QA / Production

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Abhishek Dhoriya Profile Picture
    1,013 on at
    RE: How to get Organization url or discovery url in plugin

    Hi Kavita,

    Please understand my solution once.

    See you have a custom entity say (Plugin Parameter)

    it has once field say OrgURL:

    Now create One Records of these entity in all three environments as:

    1)Name: Current Environment

      OrgURL :      your instance OrgURL

    Now in your Plugin Fetch this record with Name as Current Environment.

    And from there on you will always get current ORG URL right.

  • Rajkumar Rajaraman Profile Picture
    on at
    RE: How to get Organization url or discovery url in plugin

    The issue is that the plug-in is being deployed to the Sandbox. Since the plug-in is in the Sandbox, it is running as a partially trusted caller.

    Refer the following thread:

    social.microsoft.com/.../systemsecuritysecurityexception-that-assembly-does-not-allow-partially-trusted-callers

  • Community Member Profile Picture
    on at
    RE: How to get Organization url or discovery url in plugin

    This would work , but I'm working with CRM2011 onpremise , and it throws "SecurityException : The assembly does not allow partially trusted callers" for HttpContext .

    I'm completely stuck.

  • Suggested answer
    anilambadan Profile Picture
    1,160 on at
    RE: How to get Organization url or discovery url in plugin

    Hi Kavita,

    You may be able to create a webservice to get Organization url. So in the web.config for the web service you can put different urls for organisation service based on environments. And in your code based the url (HttpContext.Current.Request.Url.AbsoluteUri)  you can decide whether you are on which environment. then you can find out the url from the web.config based on the url.

    Otherwise you can hard code the url based on the current page's url

    if(HttpContext.Current.Request.Url.AbsoluteUri.contain("live")

    {

    url="liveurl";

    }

    else if (HttpContext.Current.Request.Url.AbsoluteUri.contains("Dev")

    {

    url="devurl";

    }

    Please note, I haven't tried the above idea.

    thanks

    Anil

  • Rajkumar Rajaraman Profile Picture
    on at
    RE: How to get Organization url or discovery url in plugin

    Kavita,

    Refer this link:

    rokhri.com/.../crm-2011-get-list-of-all-organizations-and-get-url-from-organization-details-collection

    Hope this helps.

    Regards,

    R.Rajkumar

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

  • Community Member Profile Picture
    on at
    RE: How to get Organization url or discovery url in plugin

    I want to know the organization url , so that I can decide which DB to connect. What you have proposed is getting url after connection to DB.

  • Suggested answer
    Abhishek Dhoriya Profile Picture
    1,013 on at
    RE: How to get Organization url or discovery url in plugin

    you can have use one custom entity (eg. Plugin Parameter) with URL field that you will read in your plugin , not only URL parameter but also you can add more parameter as per your wish. This approach has following benefits.

    1) You have the control to change the  Parameter value post deployment with minimal efforts.

    2) Customization is one time effort in across all environments.

    3) you can add remove Parameter as per your choice.

  • MilindP Profile Picture
    1,019 on at
    RE: How to get Organization url or discovery url in plugin

    pass if as secured parameter to the plug-in

  • Mahendar Pal Profile Picture
    45,095 on at
    RE: How to get Organization url or discovery url in plugin

    Hi Kavita,

    How about keeping these information over web resource and read web resource in your plugin.

  • Community Member Profile Picture
    on at
    RE: How to get Organization url or discovery url in plugin

    This is what we are doing already , but every time there is change to plugin , we register it  on dev and then import this solution to qa and eventually to production. Now the problem is , if I forget to change url in dev n production (this is also repetitive work) , it will point wrong database

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans