Method to look up Table data In Inspection Plan Configurator

Is it possible to use the Context.AssemblySeq to indirectly look up the JobAsmbl.PartNum to load this to an Inspection Plan Form control in the “On Load” Event expression? I am new at this and don’t find in my searches any examples of how to use these:
image

The other thought I had was could we increase the fields that are supplied with the Context data to include this field we need? I was not sure if this Context list was dynamic or fixed.
image

Are you trying to get the JobAsmbl.PartNum from an existing JobAsmbl record?

If so, you can directly query the JobAsmbl table in the OnLoad event, using a LINQ expression. You might have to do it in a Server side UD Method.

Agreed. If the inspection plan is attached to JobAsmbl or JobOper the PartNum could be queried

I have never used LINQ expression. Can you send me and example that I can use to build one for this application?

string pn = Db.JobAsmbl
  .Where( r =>r.Company == MyCompany && r.JobNum == JobToFind && r.AssemblySeq == Seq)
  .Select( r =>r.PartNum)
  .DefaultIfEmpty("Not Found")
  .FirstOrDefault();

I broke that up into multiple lines for readability. Normally it’s just one long expression.

That will search the JobAsmbl table for the first record that matches all the conditions in the .Where() part. You can add more conditions. And you’ll need to replace MyCompany, JobToFind, and Seq.

If a record is found, it sets the variable pn to the value of the PartNum field.

If no matching records are found, it sets pn to "NotFound"

string pn = Db.JobAsmbl

.Where( r =>r.Company == “DTSF” && r.JobNum == Context.JobNumber && r.AssemblySeq == Context.AssemblySeq)

.Select( r =>r.PartNum)

.DefaultIfEmpty(“Not Found”)

.FirstOrDefault();

Other than what I inserted with the Context fields, if that is even correct, do i assign pn to a control with a
Inputs.epiPcTextBox1.Value = pn; statement ?

I am guessing I need to change the Db to my database name like “Epicor10” if that is the database I connect to in SSMS?

You can skip the pn variable and go right with:

Inputs.epiPcTextBox1.Value = Db.JobAsmbl.Where(r => r.Company=="DTSF" && r.JobNum == Context.JobNumber && r.AssemblySeq == Context.AssemblySeq).Select( r =>r.PartNum).DefaultIfEmpty("Not Found").FirstOrDefault();

And NO, the ‘Db’ part of that expression stays as Db (the App server only talks to the database its connected to)

As you probably know this inspection plan is being called from the Inspection Data button. This field on this End Labor Activity display is not passed along in the Context list. Can you tell me how to reference it? Is there any way to add to the available fields in the Context list? See second image.


Good Stuff thanks for the help!