I am trying to set a field value when a user copies (Duplicates) a Part and it won’t work. I tried both a pre- and post- processing Directive on Part.DuplicatePart. Seems like it should be easy.
I have searched the issue and it seems like others have struggled with this same problem but I didn’t find any specific answers. There was a coding work around. I am just trying to use the ‘Set Field’ widget and nothing else. And not a custom field either, just setting PartDescription to ‘ZZZ TEST’ and it does nothing. I know the method is firing because I inserted a Show Message widget and that gets hit.
For many methods of this sort, I use a combination of Method and Data Directives. The Method directive has a Preprocessing BPM that simply sets a callContextBpmData field to some value (such as “DuplicatePart”)
The in a Data directive, if that value has been set, then you can set the value.
Either in the Data directive or a PostProcessing Method, clear that callContextBpmData field. (I usually do it in PostProcessing as there may be multiple rows, depending on which table you are using)
I think a pre-processing directive occurs before the new part record is actually created, and a post processing directive is too late to change anything. So, in my DuplicatePart post processing directive, I have to first fill a table with the new part record, then set the fields the way I want, then Invoke Part.Update BO.
I am also deleting rows from the part revision table and formulating an email to send to production/purchasing which make this look more complicated than you need just to change a few fields. The 5 widgets highlighted may be all you need.
So close but it says the ds is not configured, I must be missing something.
When I did a fill table that worked but the update EXT would not let me choose that data set to use so it did not update the UD field. It just silently failed.
But I found a solution. It involves a very small piece of code
This was my route on this specific issue. We have a bunch of UD fields attached to PartRev that need to be reset when a part is duplicated. So I have two BPM’s:
Method directive on Erp.BO.Part.DuplicatePart that only sets a CallContextBPM field
In-tran data directive on ERP.PartRev that checks for the CCBPM field/value and if it finds it, does the actual modification to the record.