Access to general Tables from Inspection Plan Configurator

We want to pull information from a part to form our FAI and patrol Inspection Plans.

We have built our Configuration for our Inspection plan, and have also created a Configuration User Defined function we want to utilize to get some information, perhaps the run time from a Part.

We can access the Context data ( e.g. Context.JobNumber function) but then we would want to get to the JobHead table then the Part table etc.

To test we just wanted to look up the Job Number and return the Job Number, to make sure e could access the DB table.

Our User Def code is

// Enter valid C# code and don’t forget this method returns a string val
string retVal = “”;
var jh = (from r in Db.JobHead where r.Company == Context.CompanyID && r.JobNum == Context.JobNumber select r).FirstOrDefault();
retVal = Convert.ToString(jh.JobNum);
return retVal;

Our configurator.On Loaded code
Inputs.epiPcLabel1.Label = UDMethods.GETJobValue();

The error we get when picking Enter Details
Server Side Exception

Object reference not set to an instance of an object.

Exception caught in: Epicor.ServiceModel

Error Detail

Description: Object reference not set to an instance of an object.
Program: Erp.Internal.Cfg.SISTNZ.VER17.6d0654d9-4e83-4a60-89cb-28ac5d8fe0ad.dll
Method: GETJobValue
Line Number: 36
Column Number: 1
Original Exception Type: NullReferenceException
Server Trace Stack: at Erp.Internal.Cfg._InjProcessCheck.VER17.UDMethods.GETJobValue() in \sistemae10app01\epicorerp10\Server\BPM\Builds\PC_InjProcessCheck.2.46418ED7962B4EC18B85B3FF1EE791B8_InjProcessCheckUserDefined.cs:line 36
at Erp.Internal.Cfg._InjProcessCheck.VER17._InjProcessCheckServerEvents.OnLoad(ConfigurationOnLoadArgs OnLoadArgs) in \sistemae10app01\epicorerp10\Server\BPM\Builds\PC_InjProcessCheck.2.46418ED7962B4EC18B85B3FF1EE791B8_InjProcessCheckServerEvents.cs:line 32
at Erp.Internal.PC.Configuration.ConfigurationBase1.LoadConfiguration(PcValueGrpRow ttPcValueGrp, LinqRow relatedRow, LinqRow sourceRow, LinqRow foreignRow, PcStructRow ttPcStructRow, ConfigurationRuntimeParams configParams) at Erp.Services.BO.ConfigurationRuntimeSvc.StartPcValueConfiguration(ConfigurationRuntimeTableset ds, ConfigurationSequenceTableset ds2, ConfigurationRuntimeParams configParams) at Erp.Services.BO.ConfigurationRuntimeSvcFacade.StartPcValueConfiguration(ConfigurationRuntimeTableset ds, ConfigurationSequenceTableset ds2, ConfigurationRuntimeParams configParams) at SyncInvokeStartPcValueConfiguration(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at Epicor.Hosting.Wcf.EpiOperationInvoker.<>c__DisplayClass1.<Invoke>b__0(Object instance_ex) at Epicor.Hosting.OperationBoundInvoker.Invoke(Object instance, Func2 func)
at Epicor.Hosting.Wcf.EpiOperationInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

Client Stack Trace

at Epicor.ServiceModel.Channels.ImplBase1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets) at Erp.Proxy.BO.ConfigurationRuntimeImpl.StartPcValueConfiguration(ConfigurationRuntimeDataSet ds, ConfigurationSequenceDataSet ds2, ConfigurationRuntimeParams configParams) at Erp.Lib.Configurator.Runtime.ConfigurationController1.StartPcValueConfiguration(ConfigurationRuntimeDataSet configRuntimeDS, ConfigurationSequenceDataSet configSequenceDS, ConfigurationRuntimeParams configParams)

Is it possible to access the Db tables from an Inspection configuration?

jh is likely null after attempting your linq query. It must not be finding your JobHead details based on your JobNum and CompanyID.