Custom Functions in BPM Custom Code Widget

Hi All!
I would like to create a couple of small functions to use in my custom code widget. Is there a way to do this in the BPM custom code section? In C# it would be something like:

Public void DoStuff()
{
}

But this results in a ‘member declaration not allowed inside code block’ error. Is there any way to accomplish this?
Thanks!
Nate

You can use Func inside a BPM

Does that somehow allow me to write functions that I can use inside my custom code widget?
How do I implement it?

If you search a little on here there’s some good examples

https://www.epiusers.help/t/elegant-way-to-extract-year-from-vin/44869/18

@hkeric.wci is good at this stuff. I think we’d probably need to know a little more about what you’re trying to do before a real recommendation could be made.

I have searched around a bit on here and Google trying to find relevant examples. I want to know what the syntax is for creating functions (or just procedures) inside a custom code widget in a BPM. Normally member declaration is not allowed within a code block, so I am not sure how to get around it. I am looking into using Func<> but that syntax is a bit new to me. I don’t have a specific case in mind right now. In general, I would like to be able to jump around in my code a bit more by calling my own custom processes. Now I do everything with if/then/else, which is ok, but it could be cleaner if I used some functions instead. I also considered using goto and location identifiers. I want to make sure I use the best method for Epicor.
Thanks for the input!
Nate

Basically takes input(s) of a type and provides an output of a type.

This is useful particularly in BPM coding because as you might have seen by peeking at BPM source code , a custom code block is turned into a void returning method within the class that is the BPM.

So if you need some sort of function inside of a method, Func would be appropriate.

4 Likes