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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to detect Test enviroment and production environment in a plugin

(0) ShareShare
ReportReport
Posted on by 410

Hi all,

  I am trying to write a plugin to do something if it is a production environment or do something if its just the sandbox i.e Test environment. I do not know how to determine the organization name, i know that what i am looking for.  Can someone experienced help me out. Thanks 

 RaviKashyap   rthompson Arun Vinoth 

Thanks guys for helping. 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Flydancer Profile Picture
    1,332 on at

    The IExecutionContext Interface has properties like OrganizationName & OrganizationId.

    Use your PluginExecutionContext to access these properties. - I recommend comparing the IDs instead of the Name.

  • Victor Onyebuchi Profile Picture
    410 on at

    hi Flydancer, why do you recommend i use the ID instead of the name?

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi Victor,

    As mentioned below, you can use:

    msdn.microsoft.com/.../microsoft.xrm.sdk.iexecutioncontext.organizationname.aspx or msdn.microsoft.com/.../microsoft.xrm.sdk.iexecutioncontext.organizationid.aspx (if you know the organization id)

    You can also set the Secure or Unsecure configuration of the plugin step to pass different parameters to your plugin based on environment.

    sandeepkolarveettil.wordpress.com/.../how-to-read-unsecure-configuration

    Hope this helps.

  • Flydancer Profile Picture
    1,332 on at

    Hi Victor, using the ID won't break your plugins in case someone renames the Organzation (which is only possible for on-premise afaik).

    If you know this won't happen using the Name should be fine, too.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans