Trying to create my first BPM, which is a field validation, using Method Pre-processing. The idea is to check on update of a Part that the Part Class Description begins with a certain string, and give an error popup if that PartClass Description does not match.
In my Condition block I’m looking at number of rows in a Designed Query with ds.Part joined to Erp.PartClass on CompanyID and ClassID, with the Criteria on Erp.PartClass being that the Description begins with a certain string.
What happens is that the code works and the error popup occurs…but not prior to saving an incorrect PartClass value. Instead,
I update Part using an incorrect PartClass and Save. No error.
I then update that same Part, changing something else and leaving the incorrect PartClass as-is. Upon trying to Save, now I get the error popup.
So, it seems the Designed Query is not using the changed row data, but is using the already-saved row data. But I thought ‘ds’ (as in ds.Part) was intended to refer to the changed row data.
ds.Part will be the saved data. ttPart should be available in Pre-Processing and is the temporary table that will be used to update the database. Do your check against ttPart and then throw an exception from there.
Make sure that you are filtering out anything with no row mod. Many times there are two rows in the dataset, one change, and one not changed so that they can compare the two. When you do the query, filter out anything with a row mod of “”
As far as it saving, if you are actually on pre-processing, it shouldn’t. What are you using for the error. I’m assuming you are using the exception? and not just a message.
This may possibly have been the issue. Another possibility is that when I dragged ds.Part into the Designed Query, I now recall that it gave a warning something like that this table was already in use, and I would need to assign this ds.Part another instance name. I did assign an instance name, but maybe that instance was no longer a copy of the changed data, but of the saved data?
In any case, my resolution was as follows:
Since I knew that variables were properly using the changed data, I just created a variable with the Part number.
I used that as Table Criteria in the Designed Query, where I only had the PartClass table now.