Function oddness - Updating UD column, no errors but data is not saved?

I am starting to make use of functions and have come across an very strange issue. I have a function that updates a UD column on JobOper table. When I run the function using Postman no errors are reported however the UD column is not updated !?!?

Some details… the function takes in JobNum, AsmSeq and OprSeq. I have used a code widget to pull a JobEntry dataSet with GetByID, edit the UD field (called OpComp_c) and then call Update to save the changes. For debugging I set the function to return the dataset returned from the Update call. There are no errors showing up and the returned dataset has the update in it, however when I look in the database the UD field hasnt changed. I tried doing the same thing with the BO widgets and a set field by query widget and get the same result.

I have also checked I am looking at the same job in the same system as I have done that before :slight_smile:

This is the code:

this.CallService<Erp.Contracts.JobEntrySvcContract>(js => {ds = js.GetByID(jobNum);});

ds.JobOper.FirstOrDefault(op => op.AssemblySeq == asmSeq && op.OprSeq == oprSeq).SetUDField("OpComp_c", true);

this.CallService<Erp.Contracts.JobEntrySvcContract>(js => { js.Update(ref ds);});

output = JsonConvert.SerializeObject(ds);

Is there some security thing going not allowing the function to save the changes??? Note: I can edit the field in the Epicor UI with no issues.

Any hints or ideas are most welcome as this one has got me stumped!
Brett

Try including RowMod = “U” before the update.

Thanks for the tip.

Updating the code as below now results in an error of “Cannot manually update the Production Labor Rate in JobOper.” even though the ProdLabRate is not being changed…

this.CallService<Erp.Contracts.JobEntrySvcContract>(js => {ds = js.GetByID(jobNum);});

var row = ds.JobOper.FirstOrDefault(op => op.AssemblySeq == asmSeq && op.OprSeq == oprSeq);
row.SetUDField("OpComp_c", true);
row.RowMod = "U";

this.CallService<Erp.Contracts.JobEntrySvcContract>(js => { js.Update(ref ds);});

output = JsonConvert.SerializeObject(ds);

Brett

Wait a minute…That caused an event log entry that mentions BPM’s. I may have an issue with a BPM and not realise it…looking into it now…

1 Like

I disabled all the BPM’s on Job.Update and the error persisted. The reference to BPMs in the event log is now gone.

I also double checked I was able to update the UD field in Epicor without issues and that worked fine.

Brett

Any Data Directives on JobOper?

Only a change log and disabling it has no effect.

Its a weird one. Updating the UD column in JobEntry works fine.

Man, I’m coming up short.
Maybe post the full details of the error?

So I think I have figured this one out. I ended up changing my approach to call the JobEntry Rest api instead of doing it in a function but had the same issue. I was able to fix it by calling UpdateExt instead of Update. I expect if I called UpdateExt in the function that would fix the function - I haven’t tested this however.

Looks like it is a known issue… REST Services Update vs UpdateExt Methods

Cheers
Brett

3 Likes