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 do I check the Pipeline stage using code in a plugin?

(0) ShareShare
ReportReport
Posted on by 3,755

I am trying to execute two blocks of code one for pre and the other for post. I have forgotten the syntax.

Does anyone here know?

something like:

if (pre-operation){

do this

}

else if (post-operation){

do something else

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at

    Hi Hussman,

    Use this code:

    public class MyEntityPlugin: IPlugin

       {

           public void Execute(IServiceProvider serviceProvider)

           {

               var context = (IPluginExecutionContext) serviceProvider.GetService(typeof (IPluginExecutionContext));

               if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)

               {

                   if (context.Stage == 20)//Pre Stage

                   {

                       //Do your logic

                   }

                   else if (context.Stage == 40) //Post Stage

                   {

                       //Do your logic

                   }

               }

           }    

       }

    Hope this helps.

    Regards,

    R.Rajkumar

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

  • SyedHussain Profile Picture
    1,820 on at

    if (context.Stage == 20)

    {

       //Execute Code

    }

    else if (context.Stage == 40)

    {

       //Execute Other Code

    }

  • Suggested answer
    Deepesh161 Profile Picture
    6,317 on at

    msdn.microsoft.com/.../gg309673.aspx

    stages are maintained like 10,20,30 on the context

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