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)

3 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.

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

  1. I created 2 variables Company and PartNumber - both strings

  2. I set the PartNumber variable to the targetPartNumber Parameter

  3. I set the Company variable to the callContextClient.CurrentCompany

  4. Then I wrote a very small piece of code

foreach(var PartRow in (from row in Db.Part.With(LockHint.UpdLock) where row.Company == Company && row.PartNum == PartNumber select row))
{
PartRow.ProvincialProductCode_c = “”;

}

There are likely more efficient ways of doing it but after an hour of trying to set it with the field widget I will take it.

Thanks Alintz your solution led me to my solution :slight_smile:

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:

  1. Method directive on Erp.BO.Part.DuplicatePart that only sets a CallContextBPM field
  2. 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.
2 Likes