Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to detect Test enviroment and production environment in a plugin

Posted on by 390

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
    Flydancer 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 Profile Picture
    Aric Levin 30,188 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
    Victor Onyebuchi 390 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
    Flydancer 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans