Calling Function from Custom Code with many parameters

I have a function that takes in 10 parameters and I need to call it from a Custom Code Block. I have been trying to get this to work a few different ways, but have been unsuccessful.

I try to pass in a Dynamic Object, but get a “Unexpected number of arguments provided.” error, even though I have all the parameters.

dynamic parameters = new {updateType = updateType_i, partNumber = partNumber_i, description = description_i, inventoryType = inventoryType_i, shipLength = shipLength_i, shipWidth = shipWidth_i, shipHeight = shipHeight_i, shipWeight = shipWeight_i, liftGate = liftGate_i, user = user_i };
this.InvokeFunction(“FuncLibrary”,“PartMaster”, parameters);

I’ve tried using nested tuples, but that also failed with this error “Tuple based version supports not more than seven input or output argument”
var parameters = Tuple.Create(updateType_i, partNumber_i, description_i, inventoryType_i, shipLength_i, shipWidth_i,Tuple.Create( shipHeight_i, shipWeight_i, liftGate_i, user_i));
this.InvokeFunction(“WMSInterface”,“PartMaster”, parameters);

Is there something I am missing?
2021.2.21

Just add your parameters. No need for tuples or anything else.

this.InvokeFunction(“FuncLibrary”,“PartMaster”, param1, param2, ..., paramN);
1 Like

amazing. not sure why I didn’t think of that haha. Thanks!

1 Like

Two different people, same question, same day :rofl:

everything i found online was saying to use nested tuples or dynamic objects. Glad it was a simple resolution lol

1 Like

Old form.
They made it easier, lol.

1 Like

For once.

Hey–you weren’t around for the pre-release of app studio. It IS getting easier, lol.

2 Likes

Wake me up when they realize they should have went with Blazor or something similar.

May as well induce a coma.

Curious, what is App Studio based on, or is it homegrown ?
I like the way the layout stuff works, but the parameter/property setting stuff I’ve grown to hate

Blazor was not even released when this started friend!

2 Likes

Like Jose said, Blazer was just a gleam in the eye of Mr. Sanderson. However, in an API world, the actual UI means less, so for certain commands, creating a dedicated app in any framework is much easier.

2 Likes

It’s not the first, nor the last time I put my foot in my mouth :beers:

golden retriever gifofdogs GIF by Rover.com

2 Likes

Actually because of MetaUX someone who has a lot of time on their hands @klincecum :joy: could take Meta UX Output and build a brand new UI Experience

Meta UX tells you what controls and what their binding is, but you could write your own client to parse / render that. Someone should try, Not me I’ve been at this too long and frankly I’m tired :joy:

1 Like

Uh… maybe with a team!

@hmwillett - how can I get the output parameters? I noticed that I only pass the input parameters this way.

Set it to a variable.

var response = this.InvokeFunction(“FuncLibrary”,“PartMaster”, param1, param2, ..., paramN);

What is the object that I’m receiving? Doesn’t convert to an integer. I’m just capable enough to be dangerous but probably not equipped enough to figure it out on my own.

Try response.YourFuncOutVariable.

If not, my go to is Ice.Diagnostics.Log.WriteEntry(Newtonsoft.Json.JsonConverter.SerializeObject(response));
That’ll write the object to your event viewer on the server.