Save information in Jiwa through external application  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Save information in Jiwa through external application

Postby nexio » Sat Jun 10, 2017 8:00 pm

Hi everyone,

We are trying to build an external application in ASP.NET (C#) for Service Manager. The application would get debtor and invoice details and user can select the item to return.

The issue we are facing is when writing the information to Jiwa.

We set the value we want to change (for eg. JobNo) and then Save(), it does not save the information in the database and hence is not reflected when the data is read again. The code used is as follows:

Code: Select all
            JiwaFinancials.Jiwa.JiwaServiceManager.Job smjob = Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaServiceManager.Job>(null);
            smjob.Find(JiwaFinancials.Jiwa.JiwaApplication.IJiwaNavigable.ReadModes.Actual, "SM_Jobs.JobNo", "123456", "");//Searching for the entry with the specified Job Number
            smjob.JobNo = "654321"; //Set new job number
            DisplayLabel.Text = smjob.JobNo; // Displaying the new Job number (it shows the changed job number).
            smjob.Save();

If we restart the application or check in database, the value does not change.

Tried another method for reading the values and it gives same result (i.e. does not save the information):
Code: Select all
            smjob.Read("RecIDoftheJob");
            smjob.JobNo = "654321"; // Set the new job number.
            smjob.Save();


There is another function, Setup() which gives an error saying unable to Add, which caught our attention as the error said:
Add failed. Duplicate key value supplied.

I am hoping that the Setup() will add a new row to the table. If not can you please let us know how to add a new row or create a new job.

Thanks
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Save information in Jiwa through external application

Postby Mike.Sheen » Sun Jun 11, 2017 3:11 pm

Hi Nexio,

We use a convention for our maintenance type business logic to invoke the CreateNew() method to create a new record.

In the case of Service Jobs, the CreateNew() method is overridden such that you need to provide a DebtorID:

Code: Select all
JiwaFinancials.Jiwa.JiwaServiceManager.Job smjob = Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaServiceManager.Job>(null);
smjob.CreateNew("0000000061000000001V"); // Debtor account 1001 - Brown's Computer Centre has a DebtorID of 0000000061000000001V in demo data
smjob.JobNo = "654321"; //Set new job number
smjob.Save();


You don't need to set the job number - if you don't, the system will generate one for you.

Mike
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: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Save information in Jiwa through external application

Postby nexio » Mon Jun 12, 2017 9:57 pm

Hi Mike,

Thanks for the reply. Although it didn't work when we set CreateNew("DebtorID") along with Account Number, Job Number, Invoice Number etc., and also tried just using the CreateNew("DebtorID"), but there is no change in the database and it doesn't reflect in Jiwa application. It could be because we are not supplying full information along with the CreateNew().

Is there any documentation of the functions, or website where we can learn about the functions and properties available in business logic of Jiwa? Specially for service manager jobs. I tried searching in the forum and Google, but couldn't find much information.
Thanks.
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Save information in Jiwa through external application

Postby SBarnes » Tue Jun 13, 2017 8:41 am

Hi Nexio

Try https://help.jiwa.com.au/Jiwa7/7.00.180/reference/Index.html

But your best option in deloping with Jiwa is to read the actual Jiwa code with tools such as:

Red Gate .net Reflector (This the one I use)
http://www.red-gate.com/products/dotnet-development/reflector/

or Just Decompile (This one is free but doesn’t have quite the same features)
http://www.telerik.com/products/decompiler.aspx

Also reading the forums on a regular basis helps as well, and of course Jiwa themselves through the forums provide a huge amount of help and advice.

The only other advice I would give on doing an external application is makes sure you have copied all the dlls from the Jiwa program directory into your project that have Jiwa in their name as I have found this fixes most issues.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Save information in Jiwa through external application

Postby nexio » Wed Jun 14, 2017 11:57 pm

Hi Stuart,

Thanks for the information. It helped a lot to find a many of the objects we required. However we still have some objects, which we tried to find, but couldn't, can you please help us locate them?

Invoiced Item List : List of items which were in a particular invoice. (SO_Sales -> Description. All rows with same invoice number.)
Item Part Number: part number of that item.
Quantity: Quantity of the product bought in that invoice.

Reason/Issue in the item: HR_DepartmentCategories -> Name

We found Notes in Service Manager in JiwaServiceManager.Task, but there is no search/find function to add it to the particular service job.

Our application requires documents to be uploaded for service manager and we found in JiwaApplication.Documents.Document, but again couldn't find search or find().

Also there is still an issue of writing the job to the database, which would reflect in Jiwa. Tried to CreateNew() but still it won't add a service job.

We tried a lot to find them, but couldn't it would mean a lot if someone can help us with them.

Thanks.
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Save information in Jiwa through external application

Postby SBarnes » Thu Jun 15, 2017 8:13 am

Hi Nexio

Some of this is older coder using the instance on the manager but should be easy to convert.

List of items which were in a particular invoice
Code: Select all
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder workorder = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder>(null);
workorder.Read(candidate.InvoiceID);
foreach(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine line in workorder.SalesOrderLines)
{
//do something here
}


part number of that item
Have a look at JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory and its ReadRecord method.

Quantity of the product bought in that invoice
have a look at the code sample above

HR_DepartmentCategories -> Name
Look at JiwaFinancials.Jiwa.JiwaApplication.Entities.Staff.Category

Notes
Its a JiwaCollection of JiwaFinancials.Jiwa.JiwaApplication.Notes.Note, you should be able to create a note and add it to the collection.

Bear in mind for some of this it may be simpler to just query the database or use the new web API.

Hope this is of some help.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Save information in Jiwa through external application

Postby nexio » Thu Jun 15, 2017 11:33 pm

Hi Stuart,

Thanks :D . That helped a lot, and we have found the variables we were looking for, except for the ones required in custom plugin.

But still it is not creating a new job, I am not sure why is that. We have supplied all the variables required, then used createnew(), but it won't register in Jiwa.

I agree with you, it is a lot easier to directly query the database, and we have already done that and written the data directly to database, which worked (the service job shows in Jiwa with all the required information), but unfortunately we cannot connect and interact with the database directly.

Thanks.
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Save information in Jiwa through external application

Postby SBarnes » Fri Jun 16, 2017 8:31 am

Hi Nexio,

Without having access to the code it would be very difficult to advise you further, my advice would be as follows send a private message to Mike Sheen from Jiwa and send the code to him as an attachment to help you. You can do this from the forums control panel.

The only other suggestions I could make would be to create a plugin to go inside Jiwa with the same code as a demo of what is not working and at specific points place the statements System.Diagnostics.Debugger.Launch(); and System.Diagnostics.Debugger.Break(); these will launch Visual Studio into the plugin code and you would be able to see whats going on.

You could also run SQL query profiler to see what statement are being executed against the database.

There are also insert and change flags on most objects, check what value these have before the save is executed.

Try creating a completely new demo database and seeing if it works, I would also check that the database your working against has valid licenses for service manager installed.

I would not be under any circumstances be executing insert or update statements against the database if you can avoid it as there is great deal of business logic that you could be by passing which could have some unforeseen side effects.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Save information in Jiwa through external application  Topic is solved

Postby Mike.Sheen » Fri Jun 16, 2017 11:06 am

Hi Nexio,

The code you are using is probably creating a job - just not with the JobNo you are setting - it's auto generating the job number for you because the System Setting "LockJobNumber" is set to true.

You can override that behaviour in your code - the following demonstrates this.
Code: Select all
class Program
{
   static void Main(string[] args)
   {
      JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Logon("localhost", "JiwaDemo175-3", JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", "password");
      JiwaFinancials.Jiwa.JiwaServiceManager.Job smjob = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaServiceManager.Job>(null);
      smjob.SystemSettings.LockJobNumber = false;
      smjob.CreateNew("0000000061000000001V"); // Debtor account 1001 - Brown's Computer Centre has a DebtorID of 0000000061000000001V in demo data
      smjob.JobNo = "654321"; //Set new job number
      smjob.Save();
   }
}


I created a new console application in C#, added a reference to JiwaApplication.dll, JiwaODBC.dll and JiwaServiceManager.dll and used the above code. When run, it creates the job.

Now, whilst I am overriding that system setting to allow job numbers to be not automatically generated - it might not be appropriate for the customer(s) you are writing your application for.

Mike
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: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Save information in Jiwa through external application

Postby nexio » Mon Jun 19, 2017 4:12 pm

Hi,

smjob.SystemSettings.LockJobNumber = false;

That worked.Job is now showing in Jiwa.

Thanks
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 14 guests