Set Field in another table Pre Process Method to Post Process

I am trying to set the SchedComment field in JobOper to a set string if JobReleased is checked in JobHead. I tried to do this as a simple condition to check if the value was change from true to false and use the Set Field widget to set the field. However this doesnt seem to do anything to that field. I have now changed to have the pre process handle the condition and the post process to set the field but no change. Any insight is appreciated.

You can try a data directive at JobHead table.

Erp.Tables.JobOper JobOper;
var JobHeadRow = ttJobHead.FirstOrDefault();
if (JobHeadRow != null)
{
string JobNum = (string)JobHeadRow.JobNum;
JobOper = (from ttJobOperRow in Db.JobOper
where ttJobOperRow.Company == Session.CompanyID
&& ttJobOperRow.JobNum == JobNum
select ttJobOperRow).FirstOrDefault();
if (JobOper != null)
{
foreach (var ttJobOperRow in Db.JobOper)
{
if (ttJobOperRow.JobNum == JobNum)
{
ttJobOperRow.CommentText = “My Test comment”;
}
}
}
}

I had no luck playing with update method to check condition and set fields with few tables involved.

Ok, i made an In-transaction Data directive with a condition to check if JobReleased was changed to true, and I set the code into a Custom Code widget. When I tested that after there was no change with the default code or when i modified it to the data i needed. Did i miss something in the setup process?


your initial BPM said to change ALL rows… you should only change the CHANGED row in a pre-processing method.
BUT that said, the JOBHEAD change does not necessarily have any CHANGED rows in the JobOpr table, so it would not see them.

ALSO, I am wondering: If you have a JOBHEAD (one record) and 10 Operations, do you want all 10 operations to have your job comment? this doesn’t necessarily seem what I would normally see.
Maybe you want to change the jobhead comment and not the operation?

Looks like your condition is causing issue. Try putting your condition in code.This will update comment text for all the operations in the job when marked released.Also, I am using Comment-Text field for testing. Mine seems to be working in Classic as well as Kinetic.

1 Like

Switching to Changed row helped fix the issue, also in this instance every operation did need to have the Scheduling Comments set to the same thing. Sadly the requests cant just be normal :(.
Thank you!

Adding the condition to the custom code worked like a charm. Thank you for all the help.

1 Like