Skip to main content

Notifications

Announcements

No record found.

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

  • Flydancer Profile Picture
    1,332 on at
    RE: How to detect Test enviroment and production environment in a plugin

    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.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,188 Moderator on at
    RE: How to detect Test enviroment and production environment in a plugin

    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.

  • Victor Onyebuchi Profile Picture
    410 on at
    RE: How to detect Test enviroment and production environment in a plugin

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

  • Verified answer
    Flydancer Profile Picture
    1,332 on at
    RE: How to detect Test enviroment and production environment in a plugin

    The IExecutionContext Interface has properties like OrganizationName & OrganizationId.

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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans