Building a part MOM on the EWB BO -- CheckIn issues

Hey,

I could surely use some assistance, a common occurrence. :slight_smile:

I’m building a part mom in a BPM off quote entry. It all looks good to a point.

I can check out the revision (it has an alt method, so checks out the revision and the alt method).

Adding operations looks okay.

At this point (after the BPM finishes) I can go to the Engineering Workbench and call up the group. I have revisions and operations, and I can approve and check in.

But if I try to use the BO to check in I get:

Server Side Exception

BPM runtime caught an unexpected exception of 'NullReferenceException' type.
See more info in the Inner Exception section of Exception Details.

Exception caught in: Epicor.ServiceModel

Error Detail 
============
Description:  BPM runtime caught an unexpected exception of 'NullReferenceException' type.
See more info in the Inner Exception section of Exception Details.
Program:  Epicor.System.dll
Method:  GetObjectSetCache
Line Number:  354
Column Number:  13
Original Exception Type:  NullReferenceException

Client Stack Trace 
==================
   at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
   at Erp.Proxy.BO.QuoteImpl.Update(QuoteDataSet ds)
   at Erp.Adapters.QuoteAdapter.OnUpdate()
   at Ice.Lib.Framework.EpiBaseAdapter.Update()
   at Erp.UI.App.QuoteEntry.Transaction.Update()

Inner Exception 
===============
Object reference not set to an instance of an object.

I swear the inputs to the method look correct (and agree with the EWB trace):

        string ipGroupID = groupID;
        string ipPartNum = parentPartNum;
        string ipRevisionNum = parentRevisionNum;
        string ipAltMethod = parentAltMethod;
        DateTime? ipAsOfDate = DateTime.Today;
        bool ipCompleteTree = false;
        bool ipValidPassword = false;
        bool ipReturn = true;
        bool ipGetDatasetForTree = true;
        bool ipUseMethodForParts = false;
        string ipAuditText = "ECO Group JT Joe's Group";
        string opMessage = "";
        string opResultString = "";
        
   this.PublishInfoMessage("(ipGroupID, ipPartNum, ipRevisionNum, ipAltMethod, ipAsOfDate, ipCompleteTree, ipReturn, ipGetDatasetForTree, ipUseMethodForParts, ipValidPassword, out opResultString): " + ipGroupID + " " + ipPartNum + " " + ipRevisionNum + " " + ipAltMethod + " " + ipAsOfDate + " " + ipCompleteTree + " " + ipReturn + " " + ipGetDatasetForTree + " " + ipUseMethodForParts + " " + ipValidPassword + " " + opResultString, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");  

        dsEngWorkbench = 
        engWorkBench.CheckIn(ipGroupID, ipPartNum, ipRevisionNum, ipAltMethod, ipAsOfDate, ipCompleteTree, ipValidPassword, ipReturn, ipGetDatasetForTree, ipUseMethodForParts, ipAuditText, out opMessage);

Note: Part of the CheckIn method seems to work. If I don’t first approve the revisions by marking them approved in ECORev and updating them I get this message:

Business Layer Exception

The Revision cannot be checked in until all Alternate Methods have been approved.

Exception caught in: Epicor.ServiceModel

Error Detail 
============
Description:  The Revision cannot be checked in until all Alternate Methods have been approved.
Program:  Erp.Services.BO.EngWorkBench.dll
Method:  CheckIn
Line Number:  8089
Column Number:  5
Table:  ECORev

Client Stack Trace 
==================
   at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
   at Erp.Proxy.BO.QuoteImpl.Update(QuoteDataSet ds)
   at Erp.Adapters.QuoteAdapter.OnUpdate()
   at Ice.Lib.Framework.EpiBaseAdapter.Update()
   at Erp.UI.App.QuoteEntry.Transaction.Update()

Anyone have an idea?

Thanks,

Joe

Update:

I have the code that does the check out, MOM work, and check in wrapped in:

using(var txscope = IceDataContext.CreateDefaultTransactionScope()) 
{

    txscope.Complete();
}

If I move the CheckIn method outside that it seems to work okay.

But if something bad happens in the check in process after the transaction scope completes the MOM(s) can be left in an indeterminate state, whereas if it all happens inside the transaction scope and we get an exception nothing is committed to the EWB.

Jog anything loose?

Thanks,

Joe

From a suggestion per Jim Kinneman:

Erp.Contracts.EngWorkBenchSvcContract **engWorkBench** = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.EngWorkBenchSvcContract>(this.Db, true);

Erp.Contracts.EngWorkBenchSvcContract **engWorkBenchCheckIn** = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.EngWorkBenchSvcContract>(this.Db, true);

I defined a different service to execute the CheckIn method. Worked great.

Thanks, Jim!

Joe

3 Likes

I was banging my head against the wall on this same thing - thanks for posting the answer and for Jim Kinneman being an absolute rock star.

3 Likes