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)

Creating a plugin for CRM Online (C# - experts help!)

(0) ShareShare
ReportReport
Posted on by

Hello,


I have created some c# code that will extract data from CRM into a flat file but I would need this to be based on a plugin in CRM. I followed this tutorial but was a bit lost on how to do this correctly.


For instance, right now my core code the one that goes out to CRM and then pulls the data is called PROGRAM.CS. But in this tutorial, it asks to create a PLUGIN.CS...can someone provide insight on how to accomplish this? For my code to run as a plugin using the code in PROGRAM.CS?

Reference:

https://msdn.microsoft.com/en-us/library/gg695782.aspx

*This post is locked for comments

I have the same question (0)
  • Joe Gill Profile Picture
    on at

    Hi Tekwise,

    A plugin does not seem like the best choice to extract data from CRM into a flat file.

    You are more likely to write a console app to query CRM and write it to a file

    Have a look at the sample code in the SDK under queries

    hth

    Joe

  • Community Member Profile Picture
    on at

    Ok, let's skip that thought for a second.

    I would need the plugin to trigger based on the status of an order.

    How could I write that piece?

  • Suggested answer
    Alessandro Graps Profile Picture
    2,664 on at

    Hi,

    you can create two plugins on POST operation: on Create and on Update. in the plugin you need to register a preimages and a post images. You can check if the status in pre is different with post images and if it is different, you can do something...

  • Community Member Profile Picture
    on at

    Thanks everyone - after replaying the plugin execution, it shows that the PreImage and PostImage is NULL. That's why the plugin is failing, what is this Pre/Post Image?

       Entity preentity = new Entity("salesorder");
                Entity postentity = new Entity("salesorder");
                if (context.PostEntityImages.Contains("PostImage") && context.PostEntityImages["PostImage"] is Entity)
                {
                    postentity = (Entity)context.PostEntityImages["PostImage"];
                }
                if (context.PreEntityImages.Contains("PreImage") && context.PreEntityImages["PreImage"] is Entity)
                {
                    preentity = (Entity)context.PreEntityImages["PreImage"];
                }
      try
                {
                    if (null != postentity && postentity.Attributes.Contains("statuscode"))
                    {
    
    // do something
    }
    catch (Exception e)
                {
                    tracingService.Trace("Exception: {0}", e.ToString());
                    throw e;
                }

  • Verified answer
    Alessandro Graps Profile Picture
    2,664 on at

    Hi,

    you can read  about crmbook.powerobjects.com/.../plug-in-images-pre-vs-post.

    When you register a step in plugin registration tools, you can create a pre or post images also.

    Thanks

    Alessandro

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    Images are basically snapshot of entity attributes data that you will select while create images, you can have pre and post image, which is basically snapshot of data before operation and after operation. You can't setup pre for create and similarly you can set post for delete. All this you can do while registering plugin.

    Thanks

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