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!

If I determine the part number in the “On Load” event, is it possible to compare that value to the entered value at the “On Field Validating” event?

I am not sure how to pass that jobPartNum variable to the validation event.

// Compare the entered PartNum with the retrieved PartNum
if (!string.IsNullOrEmpty(jobPartNum) && enteredPartNum == jobPartNum)
{
    // Validation passed
    MessageBox.Show("Validation passed: The entered PartNum matches the Job's PartNum.");
}
else
{
    // Validation failed
    throw new Exception("Validation failed: The entered PartNum does not match the Job's PartNum.");
}
The following errors were found during compile:

CS0103 - c:\Users\meissnef\AppData\Local\Temp\ConfigDump\Client\_SubcontractCertInputEventCollection.cs (59,27) - The name 'jobPartNum' does not exist in the current context 
CS0103 - c:\Users\meissnef\AppData\Local\Temp\ConfigDump\Client\_SubcontractCertInputEventCollection.cs (59,42) - The name 'enteredPartNum' does not exist in the current context 
CS0103 - c:\Users\meissnef\AppData\Local\Temp\ConfigDump\Client\_SubcontractCertInputEventCollection.cs (59,60) - The name 'jobPartNum' does not exist in the current context 
Total number of Errors: 3, Warnings 0

Hey Fred,

Sorry I am not going to be any help for you on this. We actually abandoned trying to implement the Quality Module and came up with entirely custom app using UD tables.

I wanted to give you a reply…

Sorry.

Edit: I ended up creating a hidden text field which I populated with the job part number. I can then compare in the separate event using the two fields.

Do you have a local variable defined as jobPartNum or enteredPartNum assigned by a LINQ statement?
eg:

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

Not sure what you are attempting with this?

To help the community provide the best answer, could you include as much of the information below as you can? Your question appears to be lacking some much needed context


  • Epicor Version
  • Deployment Type (Cloud, On Prem, 3rd Party Cloud etc)
  • The business problem you’re trying to solve
  • What you’ve already tried
  • Is this a Kinetic UX (Web) or Epicor Classic issue?
  • Is it related to a Method Directive, Data Directive, Function, BAQ, UBAQ, Configurator, etc.?
  • Any screenshots, error messages, or logs.
  • Any code you’ve written (or borrowed , make sure it is property formatted)
    ```
    code here
    ```
  • Steps to reproduce the issue

For tips on how to ask questions effectively, check out this guide:
Tips for Asking Questions on the Forum
clippy-hi

Hi Clint, that code you referenced is Calvin’s solution to the original thread. It is code for the Configurator that pulls the part number for the job being referenced in the Inspection Data module. I probably should have started a new thread instead of resurrecting this one. In any case, as I posted in my edit, I figured how to do it by storing the value in a hidden character field so it would be available “globally”.

1 Like