web
You’re offline. This is a read only version of the page.
close
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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans