Create New Job (Method Calls)

We are setting up a line of special parts that are intended to create a new job when the Sales order is entered. I am passing all the relevent information to an Epicor Function to do this, but I am getting hung up at the Job Assembly Level and am unsure what I am missing.

I createed trace files, and did some research on here, and it looks like the sysetem is calling the following methods on job creation:

1 GetNewJobHead
2 GetNextJobNum
3 Fill in your JobEntryData jobhead dataset
4 Update
5 GetByID (created job)
6 GetNewJobProd
7 Update
8 GetDetails
9 Update

This is working perfectly, until We get to GetNewJob Prod, where it cannot find an Assembly because it is null. I have even tried entering the relevent date for an assembly at step 3 but it still fails.

I went as far as trying to manually create a new assembly, but it keeps errororing out at the Parent Seq Number (I tried setting it to both 0 and -1 as a test but no luck either way)

JobEntrySvc.GetNewJobAsmbl() will add an assembly to your JobTableSet. Try calling that before GetNewJobProd().

5 & 8 shouldn’t be necessary. Update() returns your updated job data to you. Not sure what you’re trying to do in step 9. I also don’t see any steps for engineering and releasing the job. Those have particular requirements I wrote about in this post.

Side note: we have a similar situation: fast turnaround orders that need a job quickly. I just run MRP, net change with a short horizon so it only takes 5 minutes, every couple hours. Works well enough.

I am getting this error after calling after calling GetNewJobAsmbl
A valid Parent Assembly is required.

Exception caught in: Epicor.ServiceModel

Error Detail

Correlation ID: 366782d9-481f-4bfe-b5c7-1ba188986783
Description: A valid Parent Assembly is required.
Program: Erp.Services.BO.JobEntry.dll
Method: setupDates
Line Number: 34497
Column Number: 17
Table: JobAsmbl

I am currently passing the following value in code, should ParentAssemblySeq be something else? I also tried -1 but same error
.
jobDs.JobHead[0].JobEngineered = true;
jobDs.JobHead[0].JobFirm = true;

jobDs.JobAsmbl[0].JobNum = newJobNum;
jobDs.JobAsmbl[0].PartNum = partNum;
jobDs.JobAsmbl[0].Description = so.OrderDtl[0].LineDesc;

jobDs.JobAsmbl[0].ParentAssemblySeq = 0;
jobDs.JobAsmbl[0].Parent = 0;

I’d mimic whatever the existing JobAsmbl records look like.

Though, running a quick trace myself, I don’t see an explicit call to create a JobAsmbl record. I do see ChangeJobHeadPartNum() called right before the first update and thereabouts the top level assembly appears by itself. JobEntry has a fair number of helper methods that aid in populating defaults, rather than forcing you to construct the job table-by-table and line-by-line.

Note: I haven’t actually had to do the beginning steps of job creation myself. As I said above, there’s already a built in module that does a fine job of creating and scheduling new jobs.

Yeah not seeing anything in the trace threw me off as well.

I am calling ChangeJobHeadPartNum as well and it seems like it does not make a differance.
I am also trying to call GetDataSetfortree as well, as that appears to be included in the trace log.

I wrote a query to compare to a new job that was manually created, but I still see the ParentAssemblySeq

I don’t set a partnum, I call ChangeJobHeadPartNum and after GetNewJobProd I set JobProd[0].MakeToStockQty and run ChangeJobProdMakeToStockQty.

Then I get details.

Somewhere behind the scenes the JobAsmbl record gets made.

@gpayne That’s what I saw too. The system calls Update after ChangeJobHeadPartNum and then the trace shows the top level JobAsmbl record before I even call GetDetails.

@BrianP GetDataSetfortree is something you might need for client-side stuff. For building a job via functions, I don’t think it’s necessary. Every time you run Update, it’s returning the current tableset.

That’s also a lot of widgets. Personally, once I get to about half as many as you have here, I condense it all down into a single code block. Especially if I already have a C# block somewhere. YMMV and I accept other views on this. I just find a mass of widgets less legible than scrolling up and down code. Plus, I have a “keep your breakable stuff in as few locations as possible” ethos.

This may or may not be helpful, but since the orders already exist, have you tried just calling the OrderJobWizard BO?

warnings = "";
errors = "";
exceptions = "";

CallService<OrderJobWizSvcContract>( jobWiz => {

	try {

		//__ Set OrderJobWizard Dataset
		var ds = jobWiz.SelectAll(orderNum, true, true, true, true);
			/* Params: 
				int OrderNum, 
				bool CreateJob, 
				bool GetDetails, 
				bool ScheduleJob, 
				bool ReleaseJob;
			*/

		jobWiz.ValidateJobs( ref ds, out warnings );
		jobWiz.CreateJobs( ref ds, out errors );

	}
	catch ( System.Exception ex ) {

		exceptions = $"{ex}";
	}

});

I tried multiple attempts to get this to work and im not getting any results. Attached is the trace log of simply

entering New job number
Adding part
Setting Date

And that creates a new job with an empty Assembly but i am not seeing anything in the trace log that creates the actuall assembly and all my function calls create a job with no assembly, and therefore does not allow me to getJobProd

The first instance of JobAsmbl in this trace is in the method GetDataSetForTree, but even calling that is not Creating anything.

I tried calling GetNewAssmbly and it keeps screeming about valid parent sequence.

04_Job with part num andDate.txt (239.9 KB)

I have not done many functions, so I decided to do some for this. I accidently left out the GetByID in my first pass and got this JobAssmbl error.
image
All widgets no code.


correct jobNum status returned
image

I noticed that you are setting released on the job. There is a setting that prevents changes to jobs after they are released. If you have that set it may be causing some issues.

I made three that make a job and get details two that get the date, quantity and part from the OrderRel data. One does a make direct and one does a make to stock.