I am trying to write a DD on JobOper that will fill a field on save. I know that I am not doing something correctly but cannot figure out what. I keep on getting the following error with the following code.
Any thoughts?
Server Side Exception
BPM runtime caught an unexpected exception of ‘ConstraintException’ type.
See more info in the Inner Exception section of Exception Details.
Exception caught in: Epicor.ServiceModel
Error Detail
Correlation ID: 647ccd91-98ae-4c2f-ad73-913eb48e0675
Description: BPM runtime caught an unexpected exception of ‘ConstraintException’ type.
See more info in the Inner Exception section of Exception Details.
Program: EntityFramework.dll
Method: ThrowPropertyIsNotNullable
Original Exception Type: ConstraintException
Framework Method: set_CommentText
Framework Line Number: 1626809
Framework Column Number: 21
Framework Source: set_CommentText at offset 108 in file:line:column C:_Releases\ERP\RL10.2.500.0\Source\Server\Db\Erp.Data.910100\ErpContext.Model.cs:1626809:21
Client Stack Trace
at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet dataSets)
at Erp.Proxy.BO.OrderJobWizImpl.CreateJobs(OrderJobWizDataSet ds, String& pErrorMessages)
at Erp.Adapters.OrderJobWizAdapter.CreateJobs(String& pErrorMessages)
at Erp.UI.App.OrderJobWizEntry.Transaction.CreateJobs()
Yeah, I know the error is happening where I cut it off. Sorry I forgot to mention. Here it is, I have still been trying things so the code has changed a little.
Ok. I know the following works. Caveat is that it does not do what I want. I thought that the code would pull the Max OprSeq not including the current one that is being added. Instead, the Max OprSeq is actually the OprSeq that is currently being added.
@jkane Is it possible you are looking too early? I use this query to get the last production step in JobEntry.Update without issues. If you are doing this in transaction would your code work in standard?
LastProductionStep = (from jo in Db.JobOper
join jod in Db.JobOpDtl
on new { jo.Company, jo.JobNum, jo.AssemblySeq, jo.OprSeq } equals new { jod.Company, jod.JobNum, jod.AssemblySeq, jod.OprSeq }
where
jo.Company == ttJobHeadRow.Company && jo.JobNum == ttJobHeadRow.JobNum &&
jod.Company == ttJobHeadRow.Company && jod.JobNum == ttJobHeadRow.JobNum &&
jod.ResourceGrpID == rg
orderby jo.OprSeq descending
select jo.OprSeq).FirstOrDefault();
Anytime I am trying to track down a null value, I start by placing message boxes everywhere to help debug my code. In this case I would try a message box before you assign a value to maxOp. something like:
@Jason_Woods, I get where you are coming from and have tried a couple of things and it still is not working. I did figure out it does not like the following line. When I comment it out the code runs, but does not with it in it.
@NateS, I do not believe the error is because of a null value, instead it is because it thinks there is a property that could be set as a null. At least that is my interpretation. I am able to get the maxOp to show in a message, which is how I know that it is pulling the current op being added. I need to figure out how to get the op prior.
I have a feeling that this is C# syntax related. As in I am not doing things correctly.
@josecgomez , @hkeric.wci can one of you take a quick look? The best that I can guess is that the results of the lambda query are not compatible with int and vice versa? So whenever I try to alter the OprSeq, it cannot be used in the Where clause. Or something like that. Any help is GREATLY appreciated.
@jkane ojw uses OrderJobWizard.CreateJobs post processing you have the job completely created. You don’t get JobOpDtl records until after scheduling so if you need the resource group the job has to have already been scheduled.
I was able to run my snipit to get the last operations there, so you should be able to loop thru the operations and set your values.
@gpayne There is no job data (other than JWJobHead) in the OrderJobWiz.CreateJobs dataset. That is why I went to the DD because there was nothing in the client trace that I could grab hold of and do anything with.
That is not going to work because I need to alter the JobOpDtl records based on the prior cell. Need to keep operations in the cell it started in pending other variables.
@jkane I took @Jason_Wood’s query and put it in a DD for JobOpDtl and what I found was amazing and also not useful. The JobOper and JobOpDtl records are added quickly and random which makes sense since they have no ordering until you schedule them. After that I made another test in post processing of ojw that was able to get and assign the prior OPs resource group. Mine were all the first Op since I do not have the capabilities in my system to check.