Ok, I’m trying to write my first BPM. It is a Post-Processing Method Directive on Customer.Update. It’s a straight forward block of code that I have running both in a stand alone console app and a Customer Entry customization. As best as I can tell my problem stems from not knowing how to properly access the record being operated on. The foreach that I am using is derived from code found on this forum from a number of years ago. Here is the code I am using:
foreach (var ttCustomer_iterator in (from ttCustomer_Row in ttCustomer where ttCustomer_Row.RowMod == IceRow.ROWSTATE_ADDED || ttCustomer_Row.RowMod == IceRow.ROWSTATE_UPDATED select ttCustomer_Row))
Since debugging is non-existent, the only thing I have to go on is a series of PublishInfoMessage that I’ve sprinkled around my code and the fact that no compile errors are reported when saving the directive. So far this hasn’t helped me figure out why the foreach isn’t finding matches when I add or update a customer.
the temp table might be empty during the post processing, which is where you’re trying to look at. If you’re trying to look up a record in the database you need to access the Db.Customer table. If you’re trying to find something before it’s processed, look in the pre-processing
What did you WANT to do with the added or updated row… I am proponent of using the widgets whenever possible, and most of the time, you can do that in a pre-processing method on Customer.Update
Aaron, that could be. Either it’s empty or the row states I’m testing for are not there to be matched. I’ll have to check. I originally thought of doing this as a Data Directive instead of a Method Directive but I could’t find any examples to work with.
Tim, we’re getting ready to use the Quick Base CRM (at our parent company’s direction) and I am trying to keep the CRM data up to date based on our Epicor data by making API calls to Quick Base. So my goal here is: user updates a customer in Epicor, once Epicor is successfully updated make API call adding or updating Quick Base as needed. Sadly no widget for that to my knowledge. I chose post instead of pre because I didn’t want to update the CRM with information that hadn’t made it into Epicor.
For now I’m off to see if there are any records in the temp table during post-processing.
Yep, in POST the row mods will already have been cleared
You can do the data gathering on the PRE then pass that info forward in context varaibles and use Enable Post Processing directive i.e. Store all of the sysrowids of the rows you want to manipulate
AHhh… Also, you may have to use a “Standard” data directive on Customer table to capture “All” changes since not all customer changes use the UPDATE method.
Also, in the Customer.Update Post processing, the record DOES exist, but may not look like it is added or modified… it is only one record left. in the PRE processing there are up to TWO records… the unmodified version (RowMod = “”) and the modified version (RowMod = “U” or RowMod = “A”). but in Post processing, the only thing you have left is the new version of the values AFTER Processing.
To actually “See” the records, use a Show Message widget, and inside that, you can display the values of the records that are available in the BPM Dataset.
Thanks Chris, I had toyed with the possibility of passing data between pre and post, but ultimately decided against it.
Tim, fortunately everything we are wanting sent to the CRM at this point in the process is passed in Customer.Update. Your mentioning that the only record returned is the updated record solved my issue. I was able to remove the foreach condition and just process the single record.
As @Chris_Conn and @timshuwy explained, on Post process method directive, you actually left with one record in the tttable but without any status i.e not Added nor Updated, so if you want to capture or validate any data at this stage then create your BPM as pre process then trigger any context variable there, then capture it as a condition on the post process BPM to do what ever you want.
also it is worth mentioning if your creating/Updating the BO involved child tables then you can use foreach loop, other than that you only have one record on the tt table after updating the Database (i.e at post process stage as explained)
you may also need to modify your code to:
var ttCustomer_xRow = (from ttCustomer_Row in ttCustomer
where ttCustomer_Row.Company == Session.CompanyID
select ttCustomer_Row).FirstOrDefault();
if(ttCustomer_xRow != null)
{
//add your action custom code
}