Failed to enable constraints

I need to create a Job with the click of a button from another screen. So far, I have been able to create the JobHead information just fine, but when I go to create a Make to Stock Demand link, I get an error. I am using the GetNewJobProd method (as shown in my trace) and filling the correct parameters (as shown in my trace), but when I run it, i get the run time error of:

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Table: JobProd
Company=‘VN’ JobNum=‘2455’ PartNum=‘00S1’ OrderNum=‘0’ OrderLine=‘0’ OrderRelNum=‘0’ WarehouseCode=’’ TargetJobNum=’’ TargetAssemblySeq=‘0’ TargetMtlSeq=‘0’ SysRowID=‘00000000-0000-0000-0000-000000000000’: ForeignKeyConstraint PartProd requires the child key values (VN, 2455, 00S1) to exist in the parent table.

I’ve looked up “PartProd” and I don’t think it exists. Has anyone gotten this method to work? Do you know what I’m missing? I thank you for your help.

Code using the Method that fails:

JEAdapter.GetNewJobProd(JobEntryDS, vJobNum, vTestPNum, 0,0,0,"","",0);

You have to have the ‘parent’ job in the adapter dataset. Do a GetByID() for the jobnum first.

1 Like

Thank you good sir! Got my datasets garbled :rofl:

Chris, this does not seem to work for me, any Idea why?

using (var JEsvc = WCFServiceSupport.CreateImpl(_session, JobEntryImpl.UriPath))
var jeds = new Erp.BO.JobEntryDataSet();


                            JEsvc.GetNewJobProd(jeds, "170415", "ZFLDY120", 0, 0, 0, string.Empty, string.Empty, 0);
                        catch (Exception)
jeds = JEsvc.GetByID("170415");
JEsvc.GetNewJobProd(jeds, "170415", "ZFLDY120", 0, 0, 0, string.Empty, string.Empty, 0);

also at some point you’ll need to save the record


Have you every had this error?
\A valid Order/Line/Release is required.

JEsvc.CheckChangeJobProdOrderRelNum(1, ttx);

Lol you guys have to give me more info to go on. Maybe the code.

What is ttx in the context here? It should be jeds I would think

1 Like

According to the trace
var tts = salesOrder.GetByID(776961);
var ttx = JEsvc.GetByID(“170418”);
Erp.BO.JobEntryDataSet.JobProdRow jprow = null;
jprow = (Erp.BO.JobEntryDataSet.JobProdRow)ttx.JobProd.Rows[ttx.JobProd.Rows.Count - 1];
jprow.WarehouseCodeDescription = “Himom”;
jprow.MakeToType = “ORDER”;
jprow.OrderNum = 776961;
jprow.OrderLine = 1;
jprow.OrderRelNum = 1;


                            JEsvc.CheckChangeJobProdOrderRelNum(1, ttx);

Here are few initial things to check/consider:
That is a valid order/line/release combo
You didnt skip any updates that were in the trace (meaning the Db doesnt know about values you set)
In the trace, before CheckChange, is the RowMod set to any particular value? i.e. “U”