Add FindNum to Mass Issue to MFG

On our Job Materials we populate the Find Number (JobMtl.FindNum)
I’m trying to get this to show up in Mass Issue to MFG to help us selectively issue easier.

I’ve been messing with Method Directive, but cannot get the lookup to work correctly.

I will be replacing the LotNum field in the grid with the FindNum. I can do this with a static value successfully.

Trace log is pretty simple without customizations.

foreach (var ttMassIssue in (from row in result.MassIssue select row))
var dbJobMtlFindNum = (from row in Db.JobMtl
row.Company == Session.CompanyID &&
row.JobNum == ttMassIssue.JobNum &&
row.AssemblySeq == ttMassIssue.AssemblySeq &&
row.MtlSeq == ttMassIssue.SeqNum &&
row.PartNum == ttMassIssue.PartNum
select row).FirstOrDefault();

// string FindNum = dbJobMtlFindNum.FindNum;  
string FindNum = "TEST";

ttMassIssue.LotNum = FindNum;
// Might need these for initialize - I dont know what im doing
string ipSysRowId = Convert.ToString(ttMassIssue.SysRowID);
string pcMessage;
string pcQuestion;
string pcError;


ttMassIssue.LotNum = dbJobMtlFindNum.FindNum;

1 Like

I tried that line of code earlier but getting an error. I dont know what its looking for. Same thing with message box.
If I use a static value it shows up ttMassIssue.LotNum = “TEST”;
Anything else from JobMtl throws error.

Maybe missing Null check?

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

Correlation ID: b69a6e6e-034b-400d-9873-425c00de567b
Description: BPM runtime caught an unexpected exception of ‘NullReferenceException’ type.
See more info in the Inner Exception section of Exception Details.
Program: Erp.BO.MassIssueToMfg.BuildMassIssueBrowse.dll
Method: A001_CustomCodeAction
Original Exception Type: NullReferenceException

Client Stack Trace

at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
at Erp.Proxy.BO.MassIssueToMfgImpl.BuildMassIssueBrowse(MassIssueInputDataSet ds, String ipSysRowID, String& pcMessage)
at Erp.Adapters.MassIssueToMfgAdapter.BuildMassIssueBrowse(String ipSysRowID, String& pcMessage)
at Erp.UI.App.MassIssuetoMfgEntry.MassIssueTransaction.BuildMassIssue()

Inner Exception

Object reference not set to an instance of an object.

Sounds like that object or that property is null at that point. Better check and dig a little deeper.

1 Like

Still trying to figure out what it wants. Can get the other info fine.


Able to get ipSysRowId which I believe BO wants so it can join JobMtl.


So nothing can be used from the dbJobMtlFindNum var. I think I need to use a GetRows method or something to do my lookup. I’m searching but not really sure how to simply get results from another table that are joined from my db.results

Your approach is perfectly valid, you should probably check those tt Variables to make sure they are what you expect them to be, because for some reason you aren’t getting back any rows.

Also check the companyID, make sure that table has it populated.

I was thinking i needed to use something like this but i dont know where to get started.

JobMtlSearchSvcContract jobMtlSearchContract = Ice.Assemblies.ServiceRenderer.GetService();

I’ll validate columns im using to match exist in both spots, maybe use session for companyID. (edit: i am, ill try other things)

Start simple, verify the inputs, match on fewer things.

Build up on it, you should figure it out.

1 Like

I’m going to put it some more static values and see what happens in a message box.

I’m thinking Bool, Int, Strings are causing problems.
Just changed a couple from == to = for testing.

Victory!.. well for one result.
Let me clean it up.

Instead of Custom Code I tried this just using the ‘Update Table by Query’ widget and it worked nicely on the first go.

It hates these two. PartNum should be string in both. MtlSeq should be int in both, its called SeqNum on the other table though.


Yup thats the final issue.
Cheated and matched using QtyPer just to get some different output.


So convert the types and try again !


// This works
string combinedMessage = "";
foreach (var ttMassIssue in result.MassIssue)
    // Exclude rows where SeqNum is 0
    if (ttMassIssue.SeqNum == 0 )
        continue; // Skip the iteration for such rows

    var dbJobMtlFindNum = (from row in Db.JobMtl
                           where row.Company == callContextClient.CurrentCompany &&
                                 row.JobNum == ttMassIssue.JobNum &&
                                 row.PartNum == ttMassIssue.PartNum &&
                                 row.MtlSeq == ttMassIssue.SeqNum &&
                                 row.AssemblySeq == ttMassIssue.AssemblySeq
                           select row).FirstOrDefault();

    if (dbJobMtlFindNum != null)
        ttMassIssue.LotNum = dbJobMtlFindNum.FindNum;
        ttMassIssue.LotNum = "NODATA";

    // Create a formatted message for each ttMassIssue
    string message = $"JobNum: {ttMassIssue.JobNum}, AssemblySeq: {ttMassIssue.AssemblySeq}, SeqNum: {ttMassIssue.SeqNum}, PartNum: {ttMassIssue.PartNum}, LotNum: {ttMassIssue.LotNum}\n";
    combinedMessage += message;

// Display the combined results in a message box
string body = "Combined Results:\n\n" + combinedMessage;
this.PublishInfoMessage(body, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar", "SecondVar");

Had to exclude Mtl Seq 0 or the assembly and mtl seq would not bind.
Mtl Seq 0 is the JobHead.PartNum They just lumped it in with the results of the JobMtl when the BO runs for Mass Issue.

ChatGPT wrote a lot of it for me.

I dont know how to post the code so it looks nice, but i’ve marked it as solution.
Thanks for all the help and motivation =)

Final piece is to do customization or personalization to change the column name from ‘Lot Number’ to ‘Find Number’
We do not use lot number so that was the field I chose to replace.

I fixed it for you but you do this →

//code here
//and here

which does:

//code here
//and here

you can do singles like `text here`
which does text here

optional, you can specify a format for syntax higlighting on the first line:
Like for csharp = cs, don’t know what all options there are
//code here
//and here

I’ll try to remember that next time… Thanks again.

I do have to find another home or another way to store it on the grid, since its now writing to the part transaction log after Mass Issue. Even though we don’t use lots, I dont need that data inserted into whatever table that is.
Trans Reference probably be find and I can just append it. or Pre-pend.

Probably callContextBPMData, then overwrite with a customization.



Using ‘Reference’ column which writes to PartTran.Reference

ttMassIssue.TranReference = "Mass Issued by " + callContextClient.CurrentUserId + ". - " + dbJobMtlFindNum.FindNum;