Setting a field in Post Processing Directive

Hi Epicor community,

I have a relatively complex Method Data Directive process.
This directive has two pieces, one of which runs in Pre-Processing and then if necessary, triggers a Post-Processing.

Why this is needed to be in two pieces is because this directive is responsible for releasing the Credit-Hold and that part has to be done in the Post-Processing.
Now here is the problem.
The Credit-Override should not happen all the time, an evaluation based on Pre-Processing values determines that, and when the Post-Processing’s evaluation has finished, I need to set a flag from True to False as well.

The problem is that it seems in Post-Processing Epicor does not have access to tt tables, So I cannot just go ahead and set a column on those, so I use the Db.table function. When use that combined with Db.Validate() BPM throws an error and when I do not use Db.Validate() it just does not update the column in the database.

So I guess my question in one sentence is:
How can I update a database field that is a Customer field (ends in _c) in Post-Processing?
I am using Update directive on OrderHed table.

Regards,

Show your db update code.

Hi @klincecum

string  company   =           callContextBpmData.Character01;     
int     ordernum  =    (int) callContextBpmData.Number01; 
decimal     amount    =    (int) callContextBpmData.Number11;
 
 foreach (var OrderHedRow in (from OrderHed_Row in Db.OrderHed
                        where  OrderHed_Row.Company == company && OrderHed_Row.OrderNum == ordernum 
                        select OrderHed_Row))
                                  { 
                                  OrderHedRow.SetUDField<bool>("AutoReleasePRocessActive_c", false);
                                  OrderHedRow["AutoReleasePRocessActive_c"] = false;
                                  OrderHedRow.AutoReleasePRocessActive_c = false;
                                  
                                  OrderHedRow.SetUDField<bool>("EmailSentForAutoRelease_c", true);
                                  OrderHedRow["EmailSentForAutoRelease_c"] = true;
                                  OrderHedRow.EmailSentForAutoRelease_c = true;
                                  
                                  Db.Validate();
                                  }

And what is the full stack error?

This is a screenshot of the Post-Processing.
The BPM malfunctions and gets stick at the CustomCode (encircled in purple) and does not move to Email section:

I just realized that it is throwing an error in the MasterUpdate
I do have a BPM there as well.
All that it does is showing a BPM form

First condition in the Master BPM:

Second Condition in the Master BPM:

The BPM form:
image

Yes I was just looking at that. You’ll probably need to set that field at master update.
Probably no need to do it at the Db context there either.

So are you suggesting to move the whole Directive (Pre and Post Directives) from Update to MasterUpdate?
That would be very inconvenient…
:frowning:

No, just whatever it doesn’t like changing.

If MasterUpdate is available in a module I almost always use that because Master (usually) only runs once, whereas Update can run multiple times in one save. Might want to think about that since your BPM is going to fire off emails.

Personally, I don’t put any email alerts in BPM’s either. I shove that into a Function that’s scheduled to run periodically during business hours so users don’t get 3 emails in 2 minutes when someone is futzing with a record.

2 Likes

removing as i cannot read

This was a stupid issue.
I had a ton of directives running on the same method and this was causing conflict.
Sorry for the late response.
I missed the notifications :slight_smile: