Bpm error

I am trying to write a simple email alert but I receive an error when testing the code.
It’s a pre-processing Bpm on SalesOrder.Update

var ttOrderHed_xRow = (from ttOrderHed_Row in ttOrderHed
                      where ttOrderHed_Row.Updated()
                      select ttOrderHed_Row).FirstOrDefault();
if (ttOrderHed_xRow != null)
{
Epicor.Customization.Bpm.InfoMessage.Publish(System.Convert.ToString(ttOrderHed_xRow.ShipComment));
Epicor.Customization.Bpm.InfoMessage.Publish(System.Convert.ToString(ttOrderHed_xRow.DeliveryDate_c));
}

‘OrderHedRow’ does not contain a definition for ‘DeliveryDate_c’ and no extension method ‘DeliveryDate_c’ accepting a first argument of type ‘OrderHedRow’ could be found (are you missing a using directive or an assembly reference?)

I can’t see the error.
Can anyone assist?
Roberto

Try changing ttOrderHed_xRow.DeliveryDate_c to ttOrderHed_xRow.[“DeliveryDate_c”]

Epicor.Customization.Bpm.InfoMessage.Publish(System.Convert.ToString(ttOrderHed_xRow["DeliveryDate_c"]));

Solves the problem - need to remember to reference UD field in this manner.
Thank you.

I would offer that this could/should be done using widgets instead.

I agree with Jason you can probably use the Widget for your purpose.

Also

Jason:

I’d be interested in what your thoughts are on advantages / disadvantages of using code instead of widgets.
I tend to could exclusively - unless it’s something really straight forward like a change log in data-directive.

Roberto

One nagging concern I have with the code widgets I have written, is how compatible are they if a client wants to migrate to a SAAS installation.

Cheers,

Andrew.

I think when it comes to upgrade time the widgets are more likely to upgrade without issue while code can sometime have issues. For our upgrades I make sure we test all BPM’s that have code widgets.

Brett

Brett:
Thank you for the input.
The upgradability is most certainly a consideration for widget v code.
To aid this process:

  1. Follow good coding practices
  2. Comment your code
  3. As @hkeric.wci wrote - documentation - a letter to your future self

Roberto

Andrew:
Are widgets not portable to SAAS?
Can you explain a little further?

Roberto

I think I need to make a pinned post about this

Multi-Tenant (MT) - the former product that some users still run but has not been sold in over three years is SaaS
Public Cloud or Dedicated Tenant (DT) - the current product is also SaaS
Single Tenant (ST) - is not SaaS but IaaS - Infrastructure as a Service

MT cannot run CODE without a lot of work with Epicor. This includes code widgets. Why? In MT, multiple companies exist in one database and one can use code to see records outside of your company ID.

So if you use widgets, even code widgets, they will only not work for older customers on the MT product. Those BPMs will work on everything else moving forward.

1 Like

I use the Custom Code widget alot! Probably more than I should, because it allows me to version control my code, I keep external copies in git.

But if I break my widgets out and do code in sections, conditions, show an Warning etc… I am able to understand the workflow visually.


image

2 Likes

Hi,

Yes I’m sure the widgets will be upgradeable, but I thought I’d read somewhere that may be an issue with ‘execute custom code’ type widgets.

Are there any SAAS users out there who can shed any light on this?

Cheers,

Andrew.

1 Like

I default to code often too. However, widgets allow for non-technical people to use and modify the results. Also, Epicor will support them if they don’t function as needed.

Jason Woods
http://LinkedIn.com/in/jasoncwoods

1 Like

ONLY for MT users.

BTW, to create Code Widgets, on-prem or SaaS, users must have Advanced BPM enabled on their user record. Some on-prem users won’t allow this capability for SOX reasons. Access to the db.context can be like juggling running chainsaws - impressive but you can hurt yourself.

:man_juggling:

Oh, and yes. I have personally created code widgets in the Public Cloud (DT) with no issues. :wink:

I Strongly promote standard widgets over a C# Code Widget when practical.
ok… now define “When Practical”:

  1. if you have 2 variables to assign in the updated record… use a widget
  2. if you have a couple of conditions, and a pop-up message… use widgets
    BUT:
  3. if you have 30 variables to set, you are checking values, have 10 different error messages that could display… its time to start using C#, as it will be easier and faster to maintain.

Very often my BPMs will have four widgets and a Variable

  1. I create a variable called “errorMessage”
  2. Condition widget (to decide if code needs to run.
  3. C# Widget that clears the error message, does some work… if there is an error condition, sets the errorMessage text
  4. Condition widget that looks to see if errorMessage is populated… if so
  5. Widget to throw the error message

OH, one other thing… SOME widgets are just not as fast as you can write the code in C#… if you have a speed issue with doing widgets only, then it might be time to consider C#.

UPGRADE CONCERNS: Yes, if you write your BPM in C#, you are taking the responsibility to make sure that upgrades work. Epicor COULD/MIGHT change something… when you do it in C#, Epicor’s upgrade process will not automatically fix things… but when you use standard Widgets, there is a better chance that Epicor’s upgrade utility will fix values to work correctly after the upgrade.:

1 Like

Tim - this applies to using widgets as well. If you call a BO object and they change the method this does not upgrade but mentions changes in the release notes. Still your problem to fix! Have yet to see an upgrade fix it for you.

1 Like