Page 1 of 1

Why is this Sales Order text object null?

PostPosted: Tue Aug 28, 2018 10:01 am
by DannyC
I'm writing a plugin which gets the debtor categories 1 and 2 and displays them on the sales order header just below the branch.

It works when loading the Sales Order form.
It also works when creating a new sales order.
But it doesn't work when on the salesOrder.ReadEnd event, useful when using the previous/next buttons.

My text objects are not gettiing assigned correctly. They are ending up as null yet the syntax is identical in the other code blocks.

Can you critique my code and find out why the salesOrder.ReadEnd codeblock isn't setting the txtDebtorCat1 and txtDebtorCat2 text boxes to the value assigned? See line 121.

version 7.0.175.

Re: Why is this Sales Order text object null?

PostPosted: Thu Aug 30, 2018 10:46 am
by DannyC
Sorry to bump this, but I've been scratching my head & trying various changes to code to get this to work but I am still having trouble. Been going at it for about 2 days. Would appreciate a hint on why those objects are null on the ReadEnd event.

Re: Why is this Sales Order text object null?

PostPosted: Thu Aug 30, 2018 11:03 am
by Scott.Pearce
The plugin is working fine for me. I tested in JiwaDemo using 7.0.175.0 SR10.

Re: Why is this Sales Order text object null?

PostPosted: Thu Aug 30, 2018 11:39 am
by DannyC
Thanks for taking a look Scott.
I'm also using SR10 on JiwaDemo database.

I assume you are using the previous/next buttons, and that the different debtors on each sales order have had their categories changed to show the changes on the sales orders? Are you also checking for credit notes, because the textboxes are using the same cells on the header panel as the credit reasons.

Cheers

Re: Why is this Sales Order text object null?

PostPosted: Thu Aug 30, 2018 11:42 am
by Scott.Pearce
I set up some different categories for different debtors and was bale to scroll through the records using the next and previous buttons. The text fields updated appropriately. I did not look at any credit notes, nor did I use the search function.

Re: Why is this Sales Order text object null?

PostPosted: Thu Aug 30, 2018 2:37 pm
by DannyC
Well, good to know the code is working. Too bad it doesn't work on my environment. :?
I'll try it at the client site - maybe it'll just magically work OK.

There must be something iffy about the code as there must be an explanation why it doesn't work for me yet works for you. Would be glad to hear of anyones ideas.

EDIT: So bizarrely enough, it does actually work kinda at the client site, but only for sales orders, not credit notes.
I have removed all of my attempts to deal with credit notes in that attached version of the plugin so that it is clean of my dodgy code.
For credit notes, I want my controls to be gone. This is so that the normal Jiwa controls for credits fill that space i.e the Credit reason label & box.

Nothing I try seems to work so here is where I need some assistance. I've tried putting
Code: Select all
if (salesOrder.CreditNote == true)
in various locations and trying .Visible = False but that doesn't work. I have tried .Enabled = False but that's not working either.

If you could just import the attached & see what you can do about dealing with credit notes I'd be very grateful!

Re: Why is this Sales Order text object null?

PostPosted: Thu Aug 30, 2018 6:49 pm
by SBarnes
Hi Danny,

Check what other plugins are loaded I have seen this previously where a plugin on its own is find but two plugins can interfere with each other.

Also check that you haven't made a copy of the plugin as a backup and the copy is enabled.

Re: Why is this Sales Order text object null?  Topic is solved

PostPosted: Thu Aug 30, 2018 9:15 pm
by Mike.Sheen
Hi Danny,

The problem seems to be because you're creating new controls in the Form Load handler (which is fine) but you're also creating those controls AGAIN in the CreateNew handler.

You should only create the controls once in the life cycle of the form, and from then onward only use the controls you previously created and use that instance.

You also want to be careful about where you add them in the TableLayoutPanel, as I think adding a control to a TableLayoutPanel row and column which is already occupied might also be tripping you up - as can be see with the below screen shot of how the header appears after importing your plugin and creating a new credit note, then reading a sales order and reading back the credit note:
SOHeader.PNG

Re: Why is this Sales Order text object null?

PostPosted: Wed Sep 05, 2018 11:28 am
by DannyC
You also want to be careful about where you add them in the TableLayoutPanel


Yes, that's exactly my problem, but I haven't been able to find a fix. This is where I need the help. if it's a credit, can I delete my objects so Jiwa's objects take those cells in the header panel? If so, what is the code that would do that, as I've been unable to find it. If deleting the objects for credit notes isn't a goer (I guess they'd need to be added again for sales) what else would you suggest?

EDIT: As a workaround, instead of locating the objects in the TableLayoutPanel1 cell row 4 and 5, I'm adding them in row 4 and 6. This seems to be OK for now, but it would be good anyway to get an answer to the above.

Re: Why is this Sales Order text object null?

PostPosted: Wed Sep 05, 2018 8:06 pm
by SBarnes
Hi Danny,

Unfortunately I have run into this problem before, an upgrade to Jiwa can break you plugin as I have had happen from grim experience where Jiwa have changed what's on the form so controls could either move around or appear in different positions, so I would be interested on how we can overcome this.

Rather than re-adding the controls why don't you just set their visible property to false when you don't want them there and just add them once?