How to Clear or Reset or Reinitialize CallContextBPMData Fields?

Is there a quick and easy way to clear the BPM Data Fields, from a BPM or a Function, that will work for Cloud clients too?
Back in Progress there was a command that could be used to do this, but I cannot find any documentation on how to do this in 10.0+
There are situations where I need to reset all the BPM Data fields at will.
I didn’t know if maybe there was even a BO Method that could be called that would do this.
I thought maybe the BpMethod might have something, but I’m unsure of what many of these do.
For instance I see a method called ‘InvalidateCaches’… what does that do?
I’ve tried callContextBpmData.InitializeRow(), but that doesn’t seem to do anything.

2 Likes

I just came across this in some code… callContextBpmData.SetCharacter20Unspecified(); It’s right at the end of the code so I’m making an assumption it’s a reset.

1 Like

I had found that too, but it appears it’s for a specific field, not all of the fields, I was hoping to find something that would reset ALL the fields.

Thanks though!

1 Like

This isn’t a quick or easy way, but if you wrote it all out once it would be reusable:


foreach ( var field in callContextBpmData.Table.Columns )
{
  var fieldType = field.GetType();
  
  if ( fieldType == typeof(string) )
  {    
      callContextBpmData[field.ColumnName] = "";
  }
  
  if ( fieldType == typeof(bool) )
  {    
      callContextBpmData[field.ColumnName] = false;
  }
 
  // Keep going for decimal, DateTime, etc... 

  // I tried it with a Switch statement. It didn't like the System.Type in as the reference. 

}
1 Like

Wait, this doesn’t work like I thought.

Hold on...
CallContext.Current.SetBpmContext(new Epicor.Customization.Bpm.BpmContextWrapper(new Ice.Tablesets.ContextTableset(), Session));
1 Like

Yeah I knew my way was dumb :dumpster_fire:

1 Like

It was exactly what I was about to post before I figured there had to be a way and stumbled upon it.

Edit, my test was not successful.

2 Likes

I’m gonna find a way lol.

Never Give Up Comedy GIF by Laff

2 Likes

I thought I had it with this:

foreach ( var field in callContextBpmData.Table.Columns )
{
    var fieldType = field.GetType();
    
    callContextBpmData[field.ColumnName] = default(fieldType);
}

but it doesn’t like me putting a variable where a type should go, even though the variable is a System.Type, dangit.

image

@Rick_Bird It’s still ugly, but it works:

foreach ( var field in callContextBpmData.Table.Columns )
{
    var fieldType = field.DataType;
    
    if ( fieldType == typeof(string)    ) callContextBpmData[field.ColumnName] =  default(string);
    if ( fieldType == typeof(int)       ) callContextBpmData[field.ColumnName] =  default(int);
    if ( fieldType == typeof(decimal)   ) callContextBpmData[field.ColumnName] =  default(decimal);
    if ( fieldType == typeof(DateTime)  ) callContextBpmData[field.ColumnName] =  default(DateTime);
    if ( fieldType == typeof(DateTime?) ) callContextBpmData[field.ColumnName] =  default(DateTime?);
    if ( fieldType == typeof(bool)      ) callContextBpmData[field.ColumnName] =  default(bool);
}
2 Likes

ron burgundy GIF
I originally posted this over a year ago and got almost no hits… but now…LOL
If only it could work…

3 Likes