Can't set field in Part.DuplicatePart method directives

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.

image

thanks!

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)

2 Likes

Thanks for the reply Marjorie. So are we saying that the SetField does not work? Just trying to understand.

No, set field should work. It’s a matter of timing. It’s likely that your change is being overwritten during the process.

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.

1 Like

Please show me an example.