Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

3rd Party Web API

Posted on by Microsoft Employee

Hi all hope your well

I'm after some guide or examples so i can try and build a plugin to do the following

On creation of an order (Order Button Click in quote) PostCreate on Order entity

I would like a plugin to get the information from the order entity and pass it to a Web API in xml format that then places that information within the API Order information field and then initiates the postorderdata in the API.

The API then generates a ordernumber which i would then like to bring back in to CRM into the order entity of the order it has just posted to the API and save it in a field 

Any guidance would be great i have a rough idea on what i need to do but a few examples of something similar from the order entity would help massively

Many Thanks

Dan 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 3rd Party Web API

    Hi Michael

    That is part of my answer in getting the order number back. But i need to also send the order information to the account system. 

    The account system basically gives us a webpage that has a box for the xml data from CRM then a action to POSTORDER this then creates the order number to be brought back. From the looks of it i think i should now be able to get the order number back i could just do with a bit of guidance sending all the order information such as customer name delivery address and products that are on the order

    Regards

    Dan 

  • Suggested answer
    Micchael Profile Picture
    Micchael 390 on at
    RE: 3rd Party Web API

    Hi Dandare,

    "I was ideally after some guides / examples on building a plugin to send xml data to a web api and get the order number back"

    I'm a little bit confused.

    In crm, "plugin" means a piece of server code that you can plug in to crm pipeline messages.

    Web Api, in crm, it's an OData endpoint providing access to crm service for external (even non .net) applications.

    If you use plugins you do not need a Web Api for crm CRUD, query or other manipulations.

    As I understand you want call an external service to get a next number.

    If so then here is a couple of links how to achieve that:

    https://code.msdn.microsoft.com/How-to-call-External-WCF-42c4490d
    If you call from crm on-line (sandboxed) plugin then the best practice is here:

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

      

    BTW, I would create an indexer entity any way.

    It will help you to survive with Outlook and mobile offline modes.

    This way 3rd party service can be called after synchronization with crm and manage sequence of  offline created instances.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 3rd Party Web API

    Hi Michael

    Thank you for that information looks like it could be very useful in the future. But sadly in this situation the number will have to come from the 3rd party order/accounts system.

    I was ideally after some guides/examples on building a plugin to send xml data to a web api and get the order number back

    Many thanks for your help

    Dan

  • Suggested answer
    Micchael Profile Picture
    Micchael 390 on at
    RE: 3rd Party Web API

    Hi,

    The solutions I would recommend:

    Plugin based sync solution:
    http://celedonpartners.com/blog/celedon-autonumber-solution-for-dynamics-crm/  

    Work Flow based async solution:
    https://community.adxstudio.com/products/adxstudio-portals/releases/adxstudio-portals-7/download/ 
    Download the msi, install, AdxstudioProductivityPack solution located  %/Program Files(x86)/Adxstudio/Portals/Customizations/
    How to set up the Auto Numbering:
    https://community.adxstudio.com/products/adxstudio-productivity-features/documentation/adxstudio-auto-numbering-workflow-helper/

    There are two options of auto numbering  implementation: synchronously and asynchronously.
    Please consider:
    1. Async approach (with workflow or async plugin) cannot guaranty correct sequence due to async nature of execution.
    2. WF or async plugins will not work off-line. If your customer uses Outlook he might be notified that number will be created after synchronization with crm.
    3. Sync solution can break the sequence in case of off-line use. Outlook Client and mobile client work with db snapshot and will update the "indexer" entity out of main stream. Per each Outlook user. Then, after synchronization, you'll get many duplicated numbers.

    If you want to create your own the concept  is:
    1. Create entity to roll the index (Indexer).
        Fields for target entity type, current number (for reporting), next number (for assign)
        You can add pre-fix and post-fix fields as well.
    2. Set up the indexer per entity-target with desirable suffixes.
    3. Add to target entity a field to keep the number.
    4. Register a sync plugin on pre-create of entity or real-time workflow.
    - get indexer instance by entity-target logical name
    - get next from indexer (check if there is no duplications in crm), set up the number field
    - roll the indexer next and current (update the indexer entity).

    These are main points. You may vary if necessary.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: 3rd Party Web API

    Hi Bas

    That is pretty much what I'm after sending the order information from CRM to the order system and get the order number back.

    I completely agree it would be nice to have CRM generate the order number but sadly this can't be the case

    Is the any chance you can point me in the right directions for some example code or guides.

    Many thanks

    Dan

  • Suggested answer
    Bas van de Sande Profile Picture
    Bas van de Sande 4,383 on at
    RE: 3rd Party Web API

    Hi Dan,

    if I understand you correctly, you want another system to fill the order number in CRM?

    If that is the case, I would recommend that you create an asynchronous plugin that is registered on the create message of the order entity.

    In the plugin you have to use a FQDN (read URL) to connect to your external WebAPI.

    The reason I mention asynchronous is that you don't want that your users have to wait while the external system is being queried.

    On the other hand:

    have you ever considered to handle the autonumbering from within CRM? There are a couple of great solutions out there that you can use.

    I hope this helps you forward

    Bas

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans