Page 1 of 1

Cancelling a GRN

PostPosted: Tue Jun 16, 2020 3:59 pm
by DannyC
I have a request from a client to stop some users from creatng GRNs to certain creditors.
I can easily write a plugin to check the creditor and the user, but when I use
Code: Select all
throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();

It lands back at the newly created GRN with the creditor there in the form.

I want to either i) clear the creditor which will allow the user to just select another creditor or
ii) simulate clicking the cancel button on the ribbon so they just need to start a new GRN.

I've tried
Code: Select all
GRN.Creditor.Clear()
but that doesn't do anything.
And I am not sure of the correct syntax to simulate clicking the cancel button.

Re: Cancelling a GRN

PostPosted: Tue Jun 16, 2020 4:31 pm
by SBarnes
There is NewRecord on the Form or CreateNew on the Receival but you'll need to get a valid creditor Id first.

But a better option would be to take over the new tool click and filter the creditors they can choose in the first place by getting in on the set up before, why let them do something that you are going to stop in the first place.

Re: Cancelling a GRN  Topic is solved

PostPosted: Tue Jun 16, 2020 4:34 pm
by Scott.Pearce
Before throwing your cancel, do this:

Code: Select all
GRNForm.ReadRecord(IJiwaNavigable.ReadModes.Actual)

Re: Cancelling a GRN

PostPosted: Tue Jun 16, 2020 7:26 pm
by DannyC
Almost Scott. That function needs the ID as a string.
So I just did a simple SQL SELECT to find the most recent GRN for that warehouse & get the PackSlipID.

Works a treat now, so thanks, that will probably suffice.
Stuart's idea has merit and is worth looking into but for now GRNForm.ReadRecord(PackSlipID) does the trick.