Suming the total allocated funds

0
Hi.  I have this application I am developing that has a Funds Allocating for Supervisors.  This Entity named Supervisor_Funds has an association with the Accounts Entity which the end user can select The Supervisors from a reference selector. I have used an Xpath constrain to to only show users of the Supervisors Role in the reference selector. It works ok. But what I need is to total the Allocated funds amount under each supervisor name and show them in another grid.  I used a microflow to Retrieve the Accounts by association to get a list of funds, then I used a Aggregator to sum the funds. Then used a create object to Add a new object in another Entity named Total funds. The microflow executes in The after commit of the Supervisors_funds. But what I can't get is to total the funds under each name. Instead I get a total funds in a new line. With the name of the Supervisors. Then when I run the microflow again it creates another new line in the Grid of the total funds entity. What I want is to sum the funds each under the name of the Supervisors, but not create a new line each time. Example say I have Pamala and John.  I don't need to see two lines of Pamalas each time I add a new fund to Pamela, instead I need is to Add the new added funds to the same line of Pamala. It works well on an Entity i had in a another application for inventory management. Where I count the total qty of tools of a single category and used an edit object to edit the qty in the Tools_Category entity.. It had two Entities Tools_Category and New_tool_purchase. And they are associated. I sum the new qty of tools and used an Edit_Object to modify the NrofTools in the Tools_Category Entity. It works. But on my new case for the funds, it is different, the association is from the Accounts Entity,  And that is similar to the Tools_Category in the previous application, but I can't and don't need to modify the Accounts Entity with custom attributes for my application, I only used a the Accounts Entity to Retrieve the Usernames of Supervisors. Please Help. Any help is useful. I am confused here Regards
asked
1 answers
0

Dilan,

It sounds to me like you are most of the way there.  

From your description, you have 3 entities involved in this scenario:  Account, Supervisor_Funds and Total_Funds.  Allocated_Funds has 1 or more objects for each Supervisor and Total_Funds should have only one object for each supervisor.  Total_Funds entity is populated via an after commit microflow on the Total_Funds entity.

If that is accurate, in your after commit microflow, you should first select all of the Total_Funds objects associated with the Supervisor for the Allocated_Funds object that has just been committed.  Once you select all of these objects, you should delete them.  In this way, your after commit microflow will always get rid of existing Total_Funds objects before creating a new one.  Are you doing this in your microflow?  If you are already doing this, perhaps you can post a model share of the after commit microflow so the community can have a look?

Also, bear in mind that you'll need to implement an after delete microflow if you haven't already so that your totals stay up to date in the event that you delete an Allocated_Funds object.

Hope that helps,

Mike

****UPDATE*****

Dilan,  

You correction is accurate, my mistake.  I have constructed a small test scenario that results in this page:

The data model looks like this:

Supervisor_Funds entity has 2 events:  an After Commit and an After Delete.  Each event calls the same microflow.  That microflow looks like this:

You can access the microflow via this model share:  https://modelshare.mendix.com/models/db47db9a-3107-4382-9a4f-25d645c90af6/after-commit-total-funds

Hope that helps,

Mike

 

answered