Add Second Resource Group to Operation

Hi everyone,
I am troubleshooting an issue with my open job resource group updating BAQ.
The goal is to look at the results row of the BAQ, then add a new second resource group ID to each job/operation listed in the BAQ. The new resource group ID is passed through callContextBpmData.ShortChar02 from a customized dashboard and a textbox.

I can manually add the resource group ID to the operation from Job Entry. When I do this, the trace shows the following BO Methods: GetNewJobOpDtl, ChangeJobOpDtlResourceGrpID, and then Update.

I reproduced this inside my BPM with the following custom code element (edited for clarity):

// using Erp.Tablesets; // add this to usings

string New2ndResourceID = string.Empty;

Erp.Contracts.JobEntrySvcContract jobEntryBO = null;
jobEntryBO = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobEntrySvcContract>(Db);

foreach (var ttResults_iterator in (from ttResults_Row in ttResults where ttResults_Row.Unchanged() select ttResults_Row)) // for every line in the BAQ results do this stuff...
{

if (callContextBpmData.ShortChar02 != null) {
    New2ndResourceID=callContextBpmData.ShortChar02;
    MyJob = ttResults_iterator.JobHead_JobNum;
    MyAsm = ttResults_iterator.JobAsmbl_AssemblySeq;
    MyOp = ttResults_iterator.JobOper_OprSeq;
    var tsJobs = new JobEntryTableset();
    tsJobs = jobEntryBO.GetByID(ttResults_iterator.JobHead_JobNum);
    
    jobEntryBO.GetNewJobOpDtl(ref tsJobs, MyJob, MyAsm, MyOp);
    jobEntryBO.ChangeJobOpDtlResourceGrpID(New2ndResourceID, ref tsJobs);
    jobEntryBO.Update(ref tsJobs);
  myNew = myNew+1;
}
}

When I attempt to run this code from the Dashboard, I get a server side error, “Object reference not set to an instance of an object.” I can’t run the custom code through the BAQ editor because it expects a value to be passed through the callContextBPMData fields. I can’t seem to figure out which object is causing the error.

Can you see any obvious issues in my code? Any idea how to get more information on this error? (Full error text below.)

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:  0281dffd-24d9-406f-9801-25f562c3c41c
Description:  BPM runtime caught an unexpected exception of 'NullReferenceException' type.
See more info in the Inner Exception section of Exception Details.
Program:  EntityFramework.dll
Method:  TryGetEntityEntry
Original Exception Type:  NullReferenceException
Framework Method:  Validate
Framework Line Number:  316
Framework Column Number:  13
Framework Source:  Validate<TLinqRow> at offset 149 in file:line:column C:\_Releases\ICE\RL10.2.500.0FW\Source\Framework\Epicor.System\Data\IceDataContext.cs:316:13


Client Stack Trace 
==================
   at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
   at Ice.Proxy.BO.DynamicQueryImpl.RunCustomAction(DynamicQueryDataSet queryDS, String actionID, DataSet queryResultDataset)
   at Ice.Adapters.DynamicQueryAdapter.<>c__DisplayClass33_0.<RunCustomAction>b__0(DataSet datasetToSend)
   at Ice.Adapters.DynamicQueryAdapter.ProcessUbaqMethod(String methodName, DataSet updatedDS, Func`2 methodExecutor, Boolean refreshQueryResultsDataset)
   at Ice.Adapters.DynamicQueryAdapter.RunCustomAction(DynamicQueryDataSet queryDS, String actionId, DataSet updatedDS, Boolean refreshQueryResultsDataset)

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

EDIT: Both the BPM and customization save and “compile” without syntax errors.
EDIT: I noticed that I forgot to set New2ndResourceGroup to ShortChar02 - I fixed that now. Still same error.
EDIT: I also get the same error when I run in the BAQ editor, if I replace ShortChar02 with a literal text string.
Edit: After further debugging I have identified the offending line, though I still can’t seem to get it to work.

    jobEntryBO.ChangeJobOpDtlResourceGrpID(New2ndResourceID, ref tsJobs);

Thank you for your time!!
Nate