How to add data into a Jiwa JournalSet Grid  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

How to add data into a Jiwa JournalSet Grid

Postby sagharfrancis » Wed Jun 22, 2022 6:05 am

I created one custom plugin in which I have a list of x Objects to populate them into a Journal Set Main form grid.

Code: Select all
JiwaFinancials.Jiwa.JiwaJournalSetsUI.MainForm form = (JiwaFinancials.Jiwa.JiwaJournalSetsUI.MainForm)JiwaForm;


I got the fields property in the form but there is no method for adding data into a grid.

How do I get the Object of that grid for mapping the list data in it?
sagharfrancis
I'm new here
I'm new here
 
Posts: 7
Joined: Wed Jun 15, 2022 4:56 am

Re: How to add data into a Jiwa JournalSet Grid

Postby pricerc » Wed Jun 22, 2022 7:44 am

Jiwa libraries often provide a few different ways of achieving the same result. And often, the solution that may appear most obvious to someone new to the product, is actually a more complicated way of achieving the result than is necessary - there is often a simpler way.

With that in mind, can you provide some background about the problem you are trying to solve?

There is a good chance that some other forum user has encountered something similar and will be able to provide some advice.

Right now, I imagine most visitors, like me, are asking "why would you want to do that?".

Having said that, there are several standard/sample plugins that add custom data to grids, and a few examples here on the forums.

All Jiwa grids work the same way, but a word of warning - they may not work the way you expect: Much of the Jiwa codebase carries the legacy of decades of development, and in some places, the grid being one of them, the techniques required to use the libraries have not changed since before .NET was a thing. The JiwaGrid object is (currently) a wrapper around the FarPoint spreadsheet object, and so has to work within that product's limitations.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: How to add data into a Jiwa JournalSet Grid

Postby SBarnes » Wed Jun 22, 2022 11:55 am

Nearly every screen in Jiwa has a business object behind it in this case namely JournalSet for the screen in question.

If you add a line to the journal set object or change a line Jiwa will fire an event to redisplay either the line or lines in LinesJiwaGrid of the form which is the grid in question.

If you use any decompiler you can open the DLLs in the program directory and pretty much see what is happening, I usually start by looking at the form/ui code and looking at a method called AddHandlers which will usually give you a pretty good idea of how things are wired up, usually the eventhandler on the business object will usually make the user interface update itself to reflect on screen the change to the business object.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: How to add data into a Jiwa JournalSet Grid

Postby Scott.Pearce » Wed Jun 22, 2022 6:11 pm

Here is a concept you need to become familiar with - layers, specifically the business logic layer.

Imagine that when you look at a Jiwa form, you are actually looking at the first of a series of "layers":

User Interface Layer
Business Logic Layer
Database Layer

Let's start at the top - the "User Interface Layer". This is the layer you can see, it contains the grid controls, buttons, check-boxes, etc. along with data. The user interface layer is dumb. It reacts to you typing into it, but also reacts to events coming from the layer below (the "Business Logic Layer"). There is no intelligence here and you generally would not want to talk to it, unless you are doing GUI work - i.e. adding a button, re-acting to a button click.

The middle layer is the "Business Logic Layer". This is the layer that contains all the business "rules" - i.e. if you try and enter a negative amount for a cost, this layer will capture this condition and throw an exception. The business logic layer contains the bulk of the intelligence. This is probably where you would be doing most of you customisation work - reading business logic objects (i.e. reading a journal set object) and reading and writing to it's properties (i.e. journalSet.Description = "My Description"). And guess what - if you set a business logic property, it will throw up an event which the user interface layer above it will see, and therefore re-display as appropriate (i.e. totals will also get updated).

The bottom layer is the database layer. It is simply a data store.

Specific to your original post - I don't think you really want to be poking values into the grid, I think you want to be poking values into journalSetObject.Lines collection.
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: How to add data into a Jiwa JournalSet Grid

Postby SBarnes » Wed Jun 22, 2022 6:42 pm

One cardinal rule to note in expanding on what Scott is explaining is also never show a message box within a business logic plugin as you can't assume there is user interface present to display it.

You should throw an exception for an error, the client will catch it and show it anyhow and if you do need to show a message box check whether or not the client property on the business object is null before you try, if it is null there is no client, in other words the business object could be running probably inside one of Jiwa's services such as the REST api or scheduled plugin service.

The business objects as Scott said is where most of the rules get applied and enforced, the Addhandler function I mentioned in a form is how the user interface hooks itself up to events on the business object to be notified and update its display.

If you want to get in ahead of Jiwa's events the SetupBeforeHandlers is available in the form plugin to attach an event ahead of Jiwa's own events and you can stop Jiwa's events from firing by throwing a ClientCancelledException with an empty constructor which is in the JiwaFinacials.Jiwa.Application.Exceptions name space and stops Jiwa quietly.

Deciding to put your code in the form plugin or the business object plugin is a decision of do I want my customisation enforced over Jiwa as whole (Business Logic Plugin) or am I looking to only have what I am doing work in the screen (Form Plugin)

The best way of learning Jiwa is with a good decompiler as not only has Jiwa been architected well it is also been done consistently so working out how one form and its business objects works will go a long way to understanding how most forms work . Also a good understanding of interfaces, events, generics and delegates would also be wise.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: How to add data into a Jiwa JournalSet Grid  Topic is solved

Postby Scott.Pearce » Thu Jun 23, 2022 12:24 pm

I've attached a plugin for Jiwa 7.2.1.0 which demonstrates creating a journal set and adding lines to it, then saving:

Plugin Creating a Local Journal Set.xml
(35.75 KiB) Downloaded 43 times
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: How to add data into a Jiwa JournalSet Grid

Postby perry » Fri Jun 24, 2022 5:08 pm

Right now, I imagine most visitors, like me, are asking "why would you want to do that?".

exactly...

I will honestly suggest you to stay away from journal set. Try us, there is 95%+ chance you can achieve what you need to do without touching that...
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 10 guests