I need a hand getting this function to work.
Background: We warranty our equipment for 1 year after shipment. There is a BPM that creates a warranty job when the original job ships. There is also a BPM that launches every night using the SysTask table as a trigger to close all of the warranty jobs that are over a year old. Come to find out that the BPM to close the jobs doesn’t run through the entire BO so PartDtl table doesn’t get cleared out, nothing gets written to the change log, etc. But it does check the JobHead.JobClosed and JobHead.JobComplete.
I want to move this to a scheduled function but I can’t get it to work.
I’ve used Jose’s Kinetic Trace Utility to find the methods and recreate them both with widgets and code.
When I run it from Postman the function passes, but it doesn’t actually close the job.
Generating a curl request on the CloseJob method and running that from Postman works fine.
This is the code I have so far. The only input I have for the function is the Job Number (iJobNum).
Erp.Tablesets.JobClosingTableset JobTS = new Erp.Tablesets.JobClosingTableset();
try
{
this.CallService<Erp.Contracts.JobClosingSvcContract>
(boJob =>
{
bool f = false;
string b = "";
DateTime now = DateTime.Now;
JobTS = boJob.SelectJobByJobNum (iJobNum);
//boJob.SelectJobByJobNum (iJobNum);
boJob.EnableSerialMatching (ref JobTS, out f);
var JobRow = JobTS.JobClosing[0];
JobRow.Company = "Giggity";
JobRow.JobComplete = true;
JobRow.JobCompletionDate = now;
JobRow.JobClosed = true;
JobRow.ClosedDate = now;
boJob.OnChangeJobClosed (ref JobTS);
boJob.PreCloseJob (ref JobTS, out f);
boJob.CloseJob (ref JobTS, out b);
}
);
}
catch
{
output = "Dohh!";
}
edit - it is the CloseJob method that is failing. Setting RowMod does not fail. If I comment out the boJob.CloseJob line goes through, but obviously doesn’t close the job.
I just got it to work though. I had to add in all of the fields except the UD ones. It must be looking for something like PartNumber or somethis else. I’ll comment them out one by one and see where the problem is and update this post for anybody who runs into it in the future.
This was one of those things where you bang your head on a wall then finally ask for help and figure it out 5 minutes later.
I appreciate the assist.
You may need to send the unchanged table and the changed table in the call to validate that something is changing. Using Buffer copy or something like that.
The problem was that the completed qty did not match the production qty. There is a flag in job closing called QuantityContinue that is a required value. If QuantityContinue = 1 then it allows the quantities not to match.
Here’s the finished goods if anybody else ever needs it.