ttPart is always null on Part.Update

I’m trying to write a BPM on Part.Update. Both in the pre and post ttPart is null.

Am I doing something wrong? C# BPM code.

// Message box setup
  var mbp1 = ""; // text to appear on popup 
  var mbp2 = Ice.Common.BusinessObjectMessageType.Information; //req'd don't change 
  var mbp3 = Ice.Bpm.InfoMessageDisplayMode.Individual; 
  var mbp4 = ""; // text that appears in popup Details button ->program field 
  var mbp5 = ""; // text that appears in popup Details button ->method field 
  var p = ttPart.FirstOrDefault();  
  if ( p == null ) {  
    mbp1 = "part is null"; 
  }  else { 
    // also how do I access the fields the part record here?
         mbp1 = p.PartNum;
         - or - 
          mbp1 = p.CustomBoolean<bool>["FieldName_c"]; 
  // call popup message 
  this.PublishInfoMessage(mbp1, mbp2, mbp3, mbp4, mbp5);

This always popups up as part is null. How can I access the part record set that’s being updated so I can extract some fields from it?

Before this in the BPM do you have a condition before the code block to test to see if the ttPart.RowMod is “A” or “U”?

No. Should I?

I usually do, that way you don’t have the possibility of running code on the unchanged rows RowMod="".

What data update triggered this BPM?

The code above is the complete code inside the BPM. I’m trying to capture a change on a custom checkbox on part, then do some further actions. However it seems that the ttPart on the update is null.

I thought this should get the record that Epicor is working with :

var p = ttPart.FirstOrDefault(); 

However it does nothing. p is always null for some reason. In this case RowMod would be a property of p.

So I actually tried to see what p.RowMod outputs as and I got a null reference exception.

I think I figured it out. The field that I’m updating is on the PartPlant table and changing this line:

var p = ttPart.FirstOrDefault(); 


var p = ttPartPlant.FirstOrDefault();  

And now I get a record!

That’s what I was asking for. I’ve had times like this where I thought I was updating a part, but in reality it was another table all together.

Atleast use

ttPartPlant.Where(x => !x.Unchanged()).FirstOrDefault();
1 Like

Hi Doug,

If you’ll turn on tracing you can see what data populates when you take whatever action the application is doing.

For example, you can set the trace and clear the log file just before clicking save, and then open the trace results and see what tables have information. On something like an update you can see before and after values.


Ya, I know. I was asking Scott what data he was updating to trigger the BPM. Some of the time you’re on a form but what you’re updating is in another area. I always trace to make sure I get the right area.