Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2021 Release Wave 2Discover the latest updates and new features releasing from October 2021 through March 2022.
2021 release wave 2 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
I have a problem that i wrote a plugin that fires on update an entity field.
This plugin has a part of the code that reads a numerical value from another entity, set it to a field in the entity, then increments it by 1 in its entity.
So that the next plugin fires will read the incremented value from that entity, and so on.
But, on updating multiple records at time, the plugin fires at the same time, and some of records took the same numerical value and it seems "from my opinion" the incrementing process and updating the field in the other entity is slowly compared to the generating updates of records.
I would like to lock the part of code that of reading and updating/incrementing that value, using something like (Lock, Semaphore, Mutex) .
How can i achieve this please ?
I'm using CRM online by the way.
Thank you vey much.
You can use transactions to lock the counter entity. first update any dummy field and then read the sequence number and increment it. this will lock the counter entity and prevents other instance from reading it.
Refer below url
Hello,I faced the same scenario once. I was able to solve the problem by understanding exactly how a plugin runs. In fact, a plugin works within a transaction. You can use the transaction to lock your record by updating a dummy value.
You will find on this blog a complete explanation and an example implementation of the same design: https://bettercrm.blog/2017/05/11/making-use-of-transactions-in-dynamics-365-customer-engagement/
Hello Mehdi El Amri
Thank you for your responsive reply.
I have applied your solution and it works in blocking successfully.
But not all records that the plugin fires on updating it were created (gives me error that "The work order number must be unique"), the others are created and took a unique number.
I have generated 34 records that on each of them the plugin should fires, only 6 of them took unique number, the others failed/error.
How can i eliminate this please ?
Hello Sardar Ahmed
How can i solve this please ?
Business Applications communities