Page 1 of 1

SalesOrder.Find - RecordNotFoundException - Jiwa 7

PostPosted: Fri Apr 17, 2015 11:27 am
by mribbons
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.

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

PostPosted: Fri Apr 17, 2015 11:34 am
by Scott.Pearce
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.

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

PostPosted: Fri Apr 17, 2015 11:38 am
by Mike.Sheen
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.

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

PostPosted: Fri Apr 17, 2015 12:41 pm
by mribbons
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.

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

PostPosted: Fri May 01, 2015 11:53 am
by Mike.Sheen
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.

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

PostPosted: Tue Jun 23, 2015 11:03 am
by mribbons
Hi,
Just following up on this issue and confirming that using .ReadRecord() instead of .Find() resolved the problem.

Thanks guys.

Re: SalesOrder.Find - RecordNotFoundException - Jiwa 7

PostPosted: Tue Jun 23, 2015 10:18 pm
by Mike.Sheen
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).