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

Discussions relating to plugin development, and the Jiwa API.

Why is this Sales Order text object null?

Postby DannyC » Tue Aug 28, 2018 10:01 am

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.
Attachments
Plugin Add debtor cats to SO Header.xml
(37.66 KiB) Downloaded 143 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Why is this Sales Order text object null?

Postby DannyC » Thu Aug 30, 2018 10:46 am

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Why is this Sales Order text object null?

Postby Scott.Pearce » Thu Aug 30, 2018 11:03 am

The plugin is working fine for me. I tested in JiwaDemo using 7.0.175.0 SR10.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Why is this Sales Order text object null?

Postby DannyC » Thu Aug 30, 2018 11:39 am

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
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Why is this Sales Order text object null?

Postby Scott.Pearce » Thu Aug 30, 2018 11:42 am

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.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Why is this Sales Order text object null?

Postby DannyC » Thu Aug 30, 2018 2:37 pm

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!
Attachments
Plugin Add debtor cats to SO Header.xml
(37.59 KiB) Downloaded 65 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Why is this Sales Order text object null?

Postby SBarnes » Thu Aug 30, 2018 6:49 pm

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

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

Postby Mike.Sheen » Thu Aug 30, 2018 9:15 pm

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
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Why is this Sales Order text object null?

Postby DannyC » Wed Sep 05, 2018 11:28 am

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Why is this Sales Order text object null?

Postby SBarnes » Wed Sep 05, 2018 8:06 pm

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?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 11 guests

cron