I am looking for some advice on how to approach reaching the goal described below.
I need to get the logic of the approach figured out, so I know how to approach writing my CRM 2011 Plugin code.
Given
- I have an entity named Payments, that contains many records.
- The two fields I am concerned with in the Payments entity are the Payment Number field and the Forfeit Number field.
- Every record in the Payments entity has data in these two fields.
- Many records in the Payments entity may have the same value in the Forfeit Number field.
- Of those records that contain the same value in the Forfeit Number field, each will ALWAYS have a different number in the Payment Number Field.
When a new payment is entered, my post-operation plugin need to do the following when the user saves the new payment:
(1)Search all the payments that have same Forfeit Number as the current payment that is being entered, and (2) determine what the greatest whole number value is in the Payment Number field, among all these records. Then return that whole number, add 1 to it, and place that in the current record's Payment Number field.
Looking at the "steps of the process" shown above as (1) and (2) -- how might these actually be implemented from a process standpoint?
I can't write code to do this until I understand exactly what I need to do, and determining the logical steps to do what's listed above is where I am having difficulty.
If I know what I am looking for, I can use JQUERY within my plugin to obtain the GUID of the record, and have done that type of thing before. However in this particular situation, I don't know what I am looking for because the Payment Number field may be a 1 or it may be a 10938474 and I will never know that ahead of time. That's what I need to use this plugin to "find".
Any recommendations on the "logic of the approach" would be greatly appreciated.
*This post is locked for comments