Page 1 of 1

frmAllocations not sticking

PostPosted: Wed Sep 20, 2023 5:32 pm
by neil.interactit
Hey guys,

I mentioned in the "Finalise Shipment event" forum post that a client has me building a "Deposit Payments" sub system that allows creditor payments made ahead of a purchase order fullfillment or before shipment to be linked to the relevent POs/Shipments.

I now have the CreatesDialog<frmAllocations> appearing correctly after the Finalise Shipment step, pre-filled with the associated payments. It appears to operate correctly and normally, allowing allocation of payments, which I do then click OK and the form closes. However, when I check the creditor transactions, the allocations have not happenned.

I haven't included a sample plugin as this is a multiple plugin sub-system and it is a little hard to isolate this aspect.

I lifted the code from the JiwaFinancials.Jiwa.JiwaCreditorsUI.frmCreditor.DisplayAllocationsForm(CreditorTransaction Transaction) method as follows:
Code: Select all
_manager.DialogFactory.CreateDialog<frmAllocations>(new object[5] { transId, creditor, null, null, null }, _shipmentForm, "Creditors Maintenance").ShowDialog(_shipmentForm);

I have used _shipmentForm which is the current JiwaFinancials.Jiwa.JiwaLandedCostUI.Shipment.Shipment in place of "this" in frmCreditor.DisplayAllocationsForm (which is obviously the current frmCreditor) but I can't spot anything funky that frmAllocations is doing with the passed form.

I also tried a _manager.Database.Commit(); straight after the CreateDialog call, in case I was losing the allocations for lack of a commit, but this did not help.

Can you point out what I am missing?

Cheers,
Neil.

Re: frmAllocations not sticking  Topic is solved

PostPosted: Wed Sep 20, 2023 6:37 pm
by Mike.Sheen
neil.interactit wrote:I also tried a _manager.Database.Commit(); straight after the CreateDialog call, in case I was losing the allocations for lack of a commit, but this did not help.

Can you point out what I am missing?


You're passing a creditor object to that dialog, and that dialog will be meddling with the transactions and allocations of that object - so to save those changes you need to invoke creditor.Save() if the dialog result was Ok.

Re: frmAllocations not sticking

PostPosted: Thu Sep 21, 2023 9:04 am
by neil.interactit
Perfect! Thanks Mike.