BPM indexoutofbounds when calling function

Hi There -
I have a BPM that I am working on which will pass some data to a function to handle.
Current Function:

Signature:

Company is authorized for the function library and function library is promoted to production.
However, I am receiving an indexoutofbounds when the function is called. This should just return “test” in my out parameter and there is no other code being ran here.

BPM throws indexoutofbounds here:

I have thoroughly tested my custom code above - this code handles setting the parameters and based off criteria the function will either run or it wont (condition block)

Condition is simple:

Inside my custom code block:


if I comment out callFunc = true; then my function does not run. This does not produce any error.
If this is not commented, then my function will run as the condition will be met and I receive an indexoutofbounds error.

Invoke function block:

Configured vars:

All variables are initialized.

2 Likes

Pull all that out and just run the function and a message.

2 Likes

Don’t you :dumpster_fire: me Mister.

I am the King.

4 Likes

Trying this now :smiley:

For further info on original post while I try er out:

initialized vars

1 Like

Still receiving error

BPM:

(setfield and condition above is simple update custnum that has been in place and working for a year or so. new is function and further)

function action

configured params

outResult is a string variable in the BPM

email template simply displays outResult as debugging helper

function:

    //code blocks are better... just saying...

```
//code blocks are better… just saying…
```

1 Like

here’s the function

result = "test";

:laughing:

edit: kinetic cloud 2025.1.5

2 Likes

Confirmed also indexoutofrange on simple invoke function..

Anyone see any issues with this / can provide thoughts?

Variables all empty strings. Result returned as string

outResult variable is a string in the BPM (adding as much detail to this post as possible for sanity sake :sob:)

Function that is being called:

result = "test";

Error:

also yes, the function is promoted to production and company authorized in security tab of function. Function library has read/write access and custom code functions enabled.

I have left the function signature alone but this should not matter… there is only a single line in the function which is the result = “test”; and nothing from the signature other than the out variable result are being used.

1 Like

Confirmed that there is a bug (or gremlins) associated with response params.

I have left the code and the BPM the exact same. The only thing changed was I removed the response parameter from the signature of the function. This now runs without issue.

The indexoutofrange exception happens as soon as I add a response parameter to the function and map it to a variable in the BPM. If the response parameter is unmapped, I do not get an error.

2 Likes

Final thoughts / findings.

Function signature doesn’t matter. What matters is if you have a response parameter mapped to a variable in your BPM or not.

Working:

Produces IndexOutOfRange exception:


It doesn’t matter if you actually use this variable anywhere or not, but I receive an error as soon as I map this to any variable including a brand new one like in this example.

Function body being called in this test:

return;

Version: Kinetic Cloud 2025.1.5

1 Like

Do one more test.

Map the variable, just the one.

Add another output variable to your function.

1 Like

Testing with:

First test = ignore both out params
Result = success

Second test = only first var mapped
Result = success??? :sweat_smile: very confused now

I’m not.

Even in code this happens. Now I know what’s wrong, and how you can report it.
What I don’t know if there is a workaround for widgets.

When you call a function in code with a single return variable, it looks like this:

string wut = (string)InvokeFunction("ColdMedina", "Funky", "invariables");

When you call a function in code with a multiple return variables, it looks like this:

string wut = (string)InvokeFunction("ColdMedina", "Funky", "invariables")[0];
string wut2 = (string)InvokeFunction("ColdMedina", "Funky", "invariables")[1];

//or

var ret = InvokeFunction("ColdMedina", "Funky", "invariables");

string wut = (string)ret[0];
string wut2 = (string)ret[1];


2 Likes

Thanks for the explanation!
If none of this had worked then my next question was going to be the syntax for invoking functions within c# :laughing:

If EpicCare is the best place to report, I’ll make a low level ticket.

2 Likes

Yes please report to epicor, and link the thread as well.

1 Like

Just a guess, the input\output of functions used to be tuples (not sure if thats still case).

In C#, tuples, whether using the old Tuple class or the new ValueTuple syntax, have a maximum capacity of 8 elements for a single tuple.

If you want to confirm, copy your func, reduce the number of inputs\outputs to not exceed 8 (perhaps hardcode some of the inputs in test func). If it works, that’s your problem.

To get around it, you can pass in a dataset or serialized object.

1 Like