Way to Update JobCode field in Order Job Wizard?


We use a BPM to fill in the JobHead.JobCode field in Job Entry and it works well. It triggers off the JobReleased field and opens a BPM Call Form. The user inputs the data and the BPM updates the field.
I want to do the same thing in Order Job Wizard but its not updating. I made it trigger from the CreateJobs method of the OrderJobWiz business object. Its a post processing method that opens a BPM call form, user inputs data and it should update the JobHead.JobCode field using execute code.

foreach(JWJobHeadRow row in ds.JWJobHead)
    row.SetUDField("JobHead.JobCode", callContextBpmData.Character01);
    row.RowMod = "U";

I know the JobCode field doesn’t exist in the ds.JWJobHead table but was hoping it would update it after ther job was created.
The BPM runs fine and opens the form and even returns my confirmation message but the field doesn’t update.
Could someone help me with this code?

I figured this out with some AI help. The JobCode field isn’t directly updatable from the ds.JWJobHead table.
I used this code to take data from a BPM data form to update the JobCode field in a post processing BPM on the OrderJobWiz business object.

    // Iterate through each row in the temporary JobHead dataset
    foreach (var tempRow in ds.JWJobHead)
        string salesOrderNumber = callContextBpmData.Character01;

        // Log the intention to update the JobCode field
        Console.WriteLine($"Updating JobCode for JobNum: {tempRow.JobNum} with value: {salesOrderNumber}");

        // Fetch the corresponding JobHead record from the actual JobHead table
        var jobHeadRecord = (from jobHead in Db.JobHead
                             where jobHead.Company == tempRow.Company
                             && jobHead.JobNum == tempRow.JobNum
                             select jobHead).FirstOrDefault();

        // If the JobHead record exists, update the JobCode field
        if (jobHeadRecord != null)
            jobHeadRecord.JobCode = salesOrderNumber;
            Console.WriteLine($"JobNum: {tempRow.JobNum} updated with JobCode: {salesOrderNumber}");
            // Log if no matching JobHead record is found
            Console.WriteLine($"No matching JobHead record found for JobNum: {tempRow.JobNum}");

    // Save changes to the database

    // Confirm that the process completes successfully
    Console.WriteLine("JobCode field update process completed successfully.");
catch (Exception ex)
    // Log any exceptions that occur
    Console.WriteLine($"An error occurred: {ex.Message}");

Thanks ChatGpt