Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Understanding the time line on a CRM plugin

Posted on by 1,695

I have been spending a lot of time trying to generate a SSRS pdf from a crm plugin. After many attempts and suggestions, I think I have found the underlying problem.

My plugin creates a new record in crm and then generates a pdf report on that record. when the plugin is fired , it creates the record and the ssrs report as a pdf, but with no data, only the report template.  I have put in several checks and I know I an getting the record guid from the new record which is passed to the report. After looking and being satisfied that the permission are fine and that there are no errors in any of the CRM, SQL or Reporting services logs, it occurred to me that the record was not available when the code for the report was fired. so I tried this scenario

1. create record 1 .  The pdf was generated ( with no data )

2. Amend my plugin and hard code record 1 guid in the report generation

3. create record 2 . The pdf report was generated with live data for record 1 

This leads me to believe that

NewARUDDRecordID = service.Create(newBACSREPORT)

Dim ReportMade As Boolean

ReportMade = clsReportGenerator.GeneratePDFReport(3, NewARUDDRecordID.ToString, serviceprovider)

Would appear to be trying to generate the report before the record is committed.

So my question is, once a plugin has created a new record, is  committed whilst the plugin is still running ( ie as soon as service.create is actioned ) or not until the plugin has closed

 

 

*This post is locked for comments

  • Pete_N Profile Picture
    Pete_N 1,695 on at
    RE: Understanding the time line on a CRM plugin

    Hi David,

    I have been doing a lot of 'testing' on this and have now got to the stage that I have a new entity (ent1) which I import a record. When this record is imported a plugin (plg1) fires and creates three records in ent2.  plg1 is registered post-operation and synchronous

    on ent2 I have a plugin plg2 that creates a SSRS PDF on record create ( post operation )

    If I register plg2 as synchronous, in this instance it creates three SSRS pdf files, but they do not contain any data.

    If I register plg2 as Asynchronous, in this instance it creates one SSRS pdf files, which contains data.

    can you make any suggestions as to why this might happening. Ideally once the record is created in ent2 , I want to create the pdf file

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Understanding the time line on a CRM plugin

    If the plugin runs synchronously on stage 20 or 40, and you use the IOrganizationService instance that you derive from the plugin context, then the changes are all part of the SQL transaction that caused the plugin to fire. This means that the changes will not be visible to any code outside the transaction, until all synchronous plugins complete.

    There are 2 possible workarounds:

    1. Register the plugin to run asynchronously. I'm not certain this will work, but the SQL transaction behaviour is different
    2. Create a separate IOrganizationService instance, and use this to create your record. This will take you outside the original transaction
  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Understanding the time line on a CRM plugin

    It is unsuppoted trick

    1. Connect to SQL Server where CRM DB is located.

    2. Open SQL Management Studio, open new query with context of your CRM DB (CRM_MSCRM or other name).

    3. Execute following T-SQL Script:

    Update SdkMessageFilter

    Set IsCustomProcessingStepAllowed = 1

    Where SdkMessageId in (Select distinct SdkMessageId From sdkmessage where name = 'ExportSolution')

    4. Make IISReset.

    5. Restart plugin registration tool - ExportSolution should be available for handling with plugins.

  • Pete_N Profile Picture
    Pete_N 1,695 on at
    RE: Understanding the time line on a CRM plugin

    Hi Meenoo

    The plugin is registered as post operation

  • Suggested answer
    meenoo Profile Picture
    meenoo 7,316 on at
    RE: Understanding the time line on a CRM plugin

    Hi PeteN,

    How did you register your plugin?

    Post or pre operation?

    Thank you.

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans