Notifications
Announcements
No record found.
Hello Dynamics 365 Community,
I have a requirement where I need to subtract a value based on previous records value.
For example :
Thanks.
Hi Manny,
Here what I suggest.
Create an auto number field and while creating the record fetch the row with the previous auto number. For instance, previous auto number is 1001 and current record auto number is 1002, then you can fetch the record decrementing 1 from the current auto number.
You can also create a Pre Operation plugin, then fetch the top 1 record based on the modified on desc and fetch the Employee field and set the current record employee field.
Hope this helps
PG
you can create a field with type whole number, then use a workflow for subtracting.
Hi PG, thanks for getting back to me.
I am using model driven app, and I do not have data type auto-number. Also, I am new to programming.
I am now learning learning Pre-Op and Post-Op Plug Ins. Would it be possible for you to provide sample code?
Appreciated,
Manny Floyd
Lets try below solution:
1. Create Plugin on Record creation/Update [Based on requirement. If Add Employee allows to enter only on create then register on Create else register on both]
2. Inside Plugin, Get Previous Record. Query records order by CreatedOn/ModifiedOn Desc and get top 1 record with EmployeeField value (CurrentEmployees) - Can include if any other conditions also.
3. Read current record value "Add Employee" from Target
4. Calculate "CurrentEmployees - CurrentRecordAddEmployee" and set this to "EmployeeField" of current Record.
Refer below link for Sample Plugin Code:
community.dynamics.com/.../pre-image-and-post-image-in-dynamics-crm
Microsoft documents sites are best for learning. Here is a tutorial for Plugin development
docs.microsoft.com/.../tutorial-write-plug-in
Learning for CE Development
docs.microsoft.com/.../tutorials-resources-sdk
You can also checkout the pluralsight courses. They have a 10 day free trial.
www.pluralsight.com/.../dynamics-crm-developer-part1
Hope this links helps you in getting started.
Best Regards
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 75 Super User 2025 Season 2
Siv Sagar 52 Super User 2025 Season 2
Daniyal Khaleel 42 Most Valuable Professional