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)

Procedure for offline plug-in

(0) ShareShare
ReportReport
Posted on by 7,042

Help me how to write code for plugin that runs in offline.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Saravana,

    Actually the code is nothing much different.

    And you can use the same code.

    But you need to register in offline mode during register in the plugin reg tool

  • Verified answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Hi Aileen Gusni,

    I already register that code in online. Whether i need to register that same code in offline?

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Saravana,

    Actually you can still use the same code.

    It still uses the same code, c# and with the same logic.

    But, my suggestion, you need to consider about register both place (offline and online/server deployment) because for example, if the plugin involves the calculation or create a new record.

    Real example, say you have 2 entities:

    A. Transaction (Consumption)

    B. Product

    And in the Product, you have quantity on hand.

    Then you implement plugin that are working both, offline and server., you register both deployment with trigger on create of the Transaction entity record.

    And in offline mode, you have calculated the Quantity on hand field in the Product, everytime you have consumed and create new Transaction record it will reduce the Quantity by one.

    So, for example, value (before consumed), it was 20.

    Then, you have 5 transaction of consumption to reduce, so become 20-5 = 15.

    So the balance of Quantity on hand in Product is 15 now.

    Then, when you go Online, it will practically repeat the same things, create transaction record as well, it will trigger the plugin to run again, then it also call the plugin with the same code, then your field: Quantity on Hand, will also be reduced -1 for each transaction record created.

    So, now your quantity on hand is 15 - 5 = 10, which is not correct and not as per users expectation.

    Another example is, if you have offline plugin and online (server) plugin, that create another record, for example: After you create Account, then you create Task.

    Then, it will trigger the offline plugin first, create new Task after create an Account.

    When you go online, the Account also will be created in CRM that will trigger same code, that inside your code once Account was created, you create a Task.

    So, you will have 2 records.

    So this is the consideration to create both plugin. Usually, I only use offline plugin for validation purpose, for example: To Validate the Phone Number, to auto populate City by Postal Code, or to validate field value cannot be duplicate.

    Hope this helps!

    Thanks.

  • Aileen Gusni Profile Picture
    44,524 on at

    If you really need the offline plugin, I hope the answer can be your consideration.

    If you have many logic, then I usually split them into 2 plugin.

    1 Plugin (validation) I apply both for online and offline, and another plugin involving calculation or another record creation business logic, I usually split by creating a new plugin and only run when online.

    Thank you.

  • Verified answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Thanks a lot Aileen Gusni.

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