BPM to Set custom field in Duplicate PO BPM

I’m trying to reset back to null a couple of custom date fields but they don’t take the values on the duplicate PO business object.

Is there some trick to make these custom fields reset to null when I do Duplicate PO? Or does this Set Field thing not work at all?

Have you tried using pre-processing instead of post directive?

Yes I’ve tried putting the BPM on both PRE and POST. Neither do the action as required unfortunately.

Darn, that’s strange. Maybe a data directive could work?

I’m not too familiar with C# code from scratch.

How do you set a field in C#?
this is essentially what I want:

foreach ( var ph in ttPOHeader ) {  

  ph.FirstPublishedToPortal_c = null; 
  ph.MassPrintDate_c = null;
  
  Db.Validate(); 

}

But I know that’s not valid code. What is the Epicor syntax to pull that off?

In my experience, the Set Field widget only works reliably in an Update/UpdateExt method directive or a pre-processing data directive.

1 Like

The set field widget is probably working in a sense, but whatever you are setting must be getting overwritten down the line. You could set the tt values in code, but I think you would still run into the same issue. Any reason why a data directive wouldn’t work?

I’m not sure how to know when to trigger the DataDirective. I want these actions to only happen when Duplicate PO is selected from the PO Entry > Actions menu so that the new PO has a blank slate for these custom fields.

How would we ensure that occurs only when Duplicate PO is clicked on inside a data directive?

You could set a callContextBPMData in the pre-processing duplicate PO method (Set BPM Data field Char01=“PODupliacted” or something), then in a pre-processing data directive on POHeader, check to see if Char01 == PODuplicated (or something). Then null your fields if that’s the case.

But, it seems like you are just resetting these _c fields to be used again for this copied PO. If that’s the case, and any/all new POHeaders will have these _c values as null anyway, you could just do a data directive that sets the _c values to null for any NEW row.

1 Like

You can set all call context on a method directive that can be picked up and read by the data directive? Wow, I didn’t know that was possible.

You’ve given me some things to try so I’ll test them out and get back to this thread.

Yep! Can be really helpful in some cases. Good luck!

I was able to get some C# code on the In-Transaction BPM (Data Directive) of POHeader.

In case anyone else is curious how I was able to achieve this:

And the C# code looks like so:

// Reset Custom Fields on new PO
// This should reset these fields in case of PO duplication.

  var ph = ttPOHeader.FirstOrDefault();

  if ( ph != null ) { 
    ph.FirstPublishedToPortal_c = null;
    ph.MassPrintDate_c          = null;                   
    Db.Validate();
  }
1 Like