Method Directive Erp.SplitJob.ProcessSplitJob Post-Processing (directive 2 of 2)

Using other samples from this website, I have tried many combinations of field value assignment to update a split job’s comment fields from the original job’s comment fields. The error message received is “CS0103 - The name ‘jhn’ does not exist in the current context”. It also repeats for the jho (original job row).

I have tried the following:

  1. newJob.jhn.PartMfgComment_c = origJob.jho.PartMfgComment_c;
    Resulting errors:
    CS1061 ‘IQueryable’ does not contain a definition for ‘jhn’ and no extension method ‘jhn’ accepting a first argument of type ‘IQueryable’ could be found (are you missing a using directive or an assembly reference?)
    CS1061 ‘IQueryable’ does not contain a definition for ‘jho’ and no extension method ‘jho’ accepting a first argument of type ‘IQueryable’ could be found (are you missing a using directive or an assembly reference?)

  2. newJob.PartMfgComment_c = origJob.PartMfgComment_c;
    Resulting errors:
    CS1061 ‘IQueryable’ does not contain a definition for ‘PartMfgComment_c’ and no extension method ‘PartMfgComment_c’ accepting a first argument of type ‘IQueryable’ could be found (are you missing a using directive or an assembly reference?)
    CS1061 ‘IQueryable’ does not contain a definition for ‘PartMfgComment_c’ and no extension method ‘PartMfgComment_c’ accepting a first argument of type ‘IQueryable’ could be found (are you missing a using directive or an assembly reference?)

Here’s the custom code:

//Erp.Tables.JobHead JobHead;
using (var txscope = IceDataContext.CreateDefaultTransactionScope())
{
	// Get the Orignal Job
	var origJob = (from jho in Db.JobHead.With(LockHint.NoLock) 
						where jho.Company == callContextClient.CurrentCompany 
						&& jho.JobNum == ipJobNum 
						select jho);

	if (origJob != null)
	{	
		//Get the newly created (split) Job
		var newJob = (from jhn in Db.JobHead.With(LockHint.UpdLock) 
								where jhn.Company == callContextClient.CurrentCompany 
								&& jhn.JobNum == ipNewJobNum 
								select jhn);

		if (newJob != null)
		{      //jhn.PartRevDescription_c = jho.PartRevDescription_c;
			//newJob.jhn.PartMfgComment_c = origJob.jho.PartMfgComment_c;
			//newJob.PartMfgComment_c = origJob.PartMfgComment_c;
			jhn.PartMfgComment_c = jho.PartMfgComment_c;
		}
		Db.Validate();
		txscope.Complete();
	}
}

Without explanation and no guarantee of effectiveness, you could simply try this:

if (newJob != null)
		{      
			newJob.FirstOrDefault().PartMfgComment_c = origJob.FirstOrDefault().PartMfgComment_c;
		}
1 Like

Chris something like that should work. I have a routine on this same method that is on my convert to E10 list for today. the old and the new jobs are parameters, so you should be able to do a single assignment with the parameters
image

Here is what the abl to C spit out. I have not tested, but it looks right. just put in your variable.

Erp.Tables.JobHead org_JobHead = null;
Erp.Tables.JobHead JobHead;
foreach (var org_JobHead_iterator in (from org_JobHead_Row in Db.JobHead
                                      where org_JobHead_Row.JobNum == ipJobNum
                                      select org_JobHead_Row))
{
    org_JobHead = org_JobHead_iterator;
    foreach (var JobHead_iterator in (from JobHead_Row in Db.JobHead
                                      where JobHead_Row.JobNum == ipNewJobNum
                                      select JobHead_Row))
    {
        JobHead = JobHead_iterator;
        JobHead["Date01"] = (DateTime?)org_JobHead["Date01"];
    }
}

I think those are the keys right there, referencing the iterator.

This is code that works for us. You will have to add your company to the where, but I think this will get you there.

var oldjob = Db.JobHead.Where(j=> j.JobNum == ipJobNum).FirstOrDefault();
if(oldjob != null)
{
	var newjob = Db.JobHead.Where(j=> j.JobNum == ipNewJobNum).FirstOrDefault();
	if(newjob != null)
	{
		//BOM Modified
		newjob.CheckBox05 = oldjob.CheckBox05;
		//Build Instructions
		newjob.ShortChar02 = oldjob.ShortChar02;

	}  

	foreach(var oldja in Db.JobAsmbl.Where(ja=> ja.JobNum == ipJobNum))
	{
      var newja = Db.JobAsmbl.Where(nja=> nja.Company == oldja.Company && nja.JobNum == ipNewJobNum && nja.AssemblySeq == oldja.AssemblySeq && nja.PartNum == oldja.PartNum).FirstOrDefault();
  		
        if(newja != null)
        {
					newja.BuildInstructRev_c = oldja.BuildInstructRev_c;
	}
	}
	
}
1 Like

Thank you Chris! That worked both syntactically and functionally.
I just tested your assignment statement and it copied both comment fields without any issue.
Truly appreciate your help, and everyone’s offerings, on this issue!
Karen

1 Like