SalesOrder.Find - RecordNotFoundException - Jiwa 7  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

SalesOrder.Find - RecordNotFoundException - Jiwa 7

Postby mribbons » Fri Apr 17, 2015 11:27 am

After upgrading to Jiwa 7 (7.0.112) we get this exception from time to time when attempting to load (.Find) a sales order.

Exception of type 'JiwaFinancials.Jiwa.JiwaApplication.Exceptions.RecordNotFoundException' was thrown

The perplexing thing is that we get the error right after saving the order, so we know the order has to exist.

Jiwa6 SalesOrder didn't like saving twice, so we save the order then find it again.

This works fine 99% of the time, but once in a while we get the RecordNotFoundException.

I can only guess that the reason the error occurs is because of system load - Possibly an SQL query timing out or something to do with an asynchronous operation.

The basic process is as follows:
Code: Select all
SalesOrder jiwaOrder = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic<SalesOrder>(null);
jiwaOrder.Setup();
jiwaOrder.CreateNew(SalesOrder.NewSalesOrderTypes.e_NewSalesOrder, "1001", false, "", "", "", jc.LogicalWarehouseID);
// more setup
//... add lines etc
jiwaOrder.Save(false, false);

string InvoiceID = jiwaOrder.InvoiceID;

this.jiwaOrder.Find(JiwaFinancials.Jiwa.JiwaApplication.IJiwaNavigable.ReadModes.Actual, "SO_Main.InvoiceID", InvoiceID, "");


Note that the error can also occur if the order is created, saved, reloaded, time elapses (hours to days) then .Find is called again.

For some orders that wouldn't load the SO_History.DateProcessed field was null, but this wasn't always the case.

Looking forward to a response.
Regards,
Mike Ribbons
Micro Pacific Pty Ltd
http://www.micropacific.com.au
mribbons
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Mon Sep 01, 2014 12:02 pm

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

Postby Scott.Pearce » Fri Apr 17, 2015 11:34 am

Does the issue still occur when you use SalesOrder.ReadRecord instead of SalesOrder.Find?

SalesOrder.Find may be taking into account some sort of filter (ie. current warehouse) which is rendering the newly saved sales order non-applicable to your context at read time.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

Postby Mike.Sheen » Fri Apr 17, 2015 11:38 am

Scott.Pearce wrote:Does the issue still occur when you use SalesOrder.ReadRecord instead of SalesOrder.Find?

SalesOrder.Find may be taking into account some sort of filter (ie. current warehouse) which is rendering the newly saved sales order non-applicable to your context at read time.


+1 - I'm betting jc.LogicalWarehouseID which is the logical warehouse you create the sales order in is different to the currently logged in warehouse (JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID) - in which case Find will throw a record not found exception, but Read never will.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

Postby mribbons » Fri Apr 17, 2015 12:41 pm

Mike.Sheen wrote:Scott.Pearce wrote:
Does the issue still occur when you use SalesOrder.ReadRecord instead of SalesOrder.Find?

SalesOrder.Find may be taking into account some sort of filter (ie. current warehouse) which is rendering the newly saved sales order non-applicable to your context at read time.


+1 - I'm betting jc.LogicalWarehouseID which is the logical warehouse you create the sales order in is different to the currently logged in warehouse (JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID) - in which case Find will throw a record not found exception, but Read never will.


I know it's not an issue with the warehouse ID because we determine that before logging in to Jiwa.

I will give .Read() a go.

Any other theories would be welcome.
Regards,
Mike Ribbons
Micro Pacific Pty Ltd
http://www.micropacific.com.au
mribbons
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Mon Sep 01, 2014 12:02 pm

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7  Topic is solved

Postby Mike.Sheen » Fri May 01, 2015 11:53 am

mribbons wrote:Any other theories would be welcome.


I'd try running SQL Profiler to try and isolate the exact query which is causing the exception - it may not be the read of the actual sales order, but perhaps a missing GL account attached for certain debtors or products.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

Postby mribbons » Tue Jun 23, 2015 11:03 am

Hi,
Just following up on this issue and confirming that using .ReadRecord() instead of .Find() resolved the problem.

Thanks guys.
Regards,
Mike Ribbons
Micro Pacific Pty Ltd
http://www.micropacific.com.au
mribbons
Occasional Contributor
Occasional Contributor
 
Posts: 13
Joined: Mon Sep 01, 2014 12:02 pm

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

Postby Mike.Sheen » Tue Jun 23, 2015 10:18 pm

mribbons wrote:Hi,
Just following up on this issue and confirming that using .ReadRecord() instead of .Find() resolved the problem.

Thanks guys.


Awesome - thanks for coming back and confirming it is resolved! We often answer questions and never hear back, so it's nice to know when the response resolved the issue (and others in the future will benefit from knowing how to solve the issue if they come across the same thing).
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 0 guests