Configurator UDMethod return string[] not working

We are in the process of re-building our configurators in Kinetic.

As noted in this post, Can't use out and ref in Kinetic Configurator UD methods , we can no longer use out and ref.

There is a new string array return type which looks very promising but we have not been able to use it successfully. Our server-side UDMethods which use this return type don’t work. We don’t get an error message but the calling method exits and we don’t get a return value.

We are able to write the same method to return a delimited string which can be split by the calling method. So, we know the method is working otherwise. This work-around is okay but returning a string array would be much more elegant.

Any suggestions for debugging would be greatly appreciated.

image

Check your event logs and see if you get any messages there.

I struggled with returning an array in the past and it might have been a bug, now I am able to return arrays without issues.

You should be able to have a return type of string and then in the method you have to declare something like

String returnValue = new String[46];
Then populate it as needed

Then
return returnValue;

In your calling routine access the individual members as needed, since they are strings anything you need as a decimal or other type will need to be converted.

In your calling routine declare the array to be the same size as you are returning. if I recall just creating it as an empty array causes a problem.

Simon,

Thanks for the suggestion, it seems to generate the following error:

Ice.BLException: Missing MenuID in EpMetaFxRequest

Which doesn’t mean a lot to me, or Google. But, it’s a start.

Thanks Jim for the suggestion. I hadn’t declared the array size so I’ve made that update.

I’m getting the same behaviour but I’ll grep through the code again to be sure I’ve caught all the instances.

The other method I use to return data especially when it is more than a few items is to build a Data table in the method, then covert it to a formatted Json string to return as a string type to the caller. Then convert the Json string back into a data table in the caller. Data in the table will still be strings so can’t avoid the convert issue.

3 Likes

Thanks again Jim.

You’re starting to exceed my programming chops but I can see where passing a Data table via JSON would be very useful in some cases.

At the risk of forking this thread, do you have a code snippet handy that demonstrates how to convert from Data table to JSON and back?

You’ll get there, just remember that there are heaps of other learning resources around for working through other peoples suggestions and techniques… Dare I say your peer AI programmer buddy is a very helpful tool for learning.

2 Likes

Here’s the basic template I use:


//
// Create DataSet and Table
//
    var dataSet = new System.Data.DataSet();

    var dataTable = new System.Data.DataTable("TableDemo");

    dataTable.Clear();

    dataTable.Columns.Add( new System.Data.DataColumn( "ID",       typeof(int)    ) );
    dataTable.Columns.Add( new System.Data.DataColumn( "ASSEMBLY", typeof(string) ) );
    dataTable.Columns.Add( new System.Data.DataColumn( "NOTES",    typeof(string) ) );

    dataSet.Tables.Add( dataTable );


//
// Delegate for adding DataRows
//
    Action<System.Data.DataTable,int,string,string> AddNewRow = (dt, id, asm, note) =>
    {
        var newRow = dt.NewRow();

        newRow["ID"] = id;
        newRow["ASSEMBLY"] = asm;
        newRow["NOTES"] = note;

        dt.Rows.Add(newRow);
    };


//
// Add Data
//
    AddNewRow( dataTable, Inputs.ID_0.Value, Inputs.Assembly_0.Value, Inputs.Notes_0.Value );
    AddNewRow( dataTable, Inputs.ID_1.Value, Inputs.Assembly_1.Value, Inputs.Notes_1.Value );
    AddNewRow( dataTable, Inputs.ID_2.Value, Inputs.Assembly_2.Value, Inputs.Notes_2.Value );

    dataSet.AcceptChanges();


//
// Return DataSet as JSON
//
    string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented);

    return json;

    /*    Must add the assembly Newtonsoft.Json and a using clause to the UDMethod.     */
4 Likes

Thanks very much for sharing that code. This will give me (and others I’m sure) a great boost.

I still plan to troubleshoot the string array issue in the OP and report back.

@Jkinneman , we were able to get this to work as a Client method after explicitly declaring the array sizes. Thanks again for that tip.

However, when we move the same method to a Server type, it exits as noted above. It’s literally a copy/paste of the same code.

Is there a different syntax we need to use in a Server method? Any help would be appreciated.

There are a few things that work client-side but not server-side, and vice-versa. Can you post the complete code?

1 Like

We made some super simple test methods as follows:

Client method:

// Client Method for returning a string array
string[] strTmp = new string[4];
    strTmp[0] = "Testing Client Method";
    strTmp[1] = "One";
    strTmp[2] = "Two";
    strTmp[3] = "Three";
return strTmp;

Server method:

// Server Method for returning a string array
string[] strTmp = new string[4];
    strTmp[0] = "Testing Server Method";
    strTmp[1] = "Four";
    strTmp[2] = "Five";
    strTmp[3] = "Six";
return strTmp;

The calling method dumps the returned values to a text area:

// Debug routine
Inputs.edtBlockOutput.Value += "**** Start - btnDebug_Clicked ****\r\n";

Inputs.edtBlockOutput.Value += "---- Call returnStringArray ----\r\n";
string[] strTestClient = new string[4];
strTestClient = await returnStringArray();
Inputs.edtBlockOutput.Value += $"Returns:\r\n{strTestClient[0]}\r\n{strTestClient[1]}\r\n{strTestClient[2]}\r\n{strTestClient[3]}\r\n";

Inputs.edtBlockOutput.Value += "---- Call returnStringArrayServer ----\r\n";
string[] strTestServer = new string[4];
strTestServer = await returnStringArrayServer();
Inputs.edtBlockOutput.Value += $"Returns:\r\n{strTestServer[0]}\r\n{strTestServer[1]}\r\n{strTestServer[2]}\r\n{strTestServer[3]}\r\n";

Inputs.edtBlockOutput.Value += "**** End - btnDebug_Clicked ****\r\n";

The calling method dumps the following to the text area control and exits before adding the “**** End…” line to the output.

**** Start - btnDebug_Clicked ****
---- Call returnStringArray ----
Returns:
Testing Client Method
One
Two
Three
---- Call returnStringArrayServer ----

Getting arrays to work was a pain. I’ll get you a complete example a little later today, have to get my Monday morning administrative stuff out of the way first.

1 Like

Opened a support ticket on it: CS0004750009.

using a classic configurator, I will test this in Kinetic next

image

Client side, it is called as an on leave event for one of the radio buttons.
image

Result
image

We have a bug with Kinetic. Code works fine in Classic, but not in Kinetic. Kinetic doesn’t handle a server side method that returns a string array. Gives no error or indication that things aren’t working.

This code when attached to a button click just looks at me, no message comes up. If I comment out the call to ServerSide method I get the messageBox slide out.
string strTmp = new string[4];

strTmp = await ServerSide();

MessageBox.Show(strTmp[0] + “:” + strTmp[1]);

Thanks very much for testing this @Jkinneman.

We were hoping it was a PEBCAK but it’s gratifying to know we’re not crazy, at least as it relates to this issue.

1 Like

Glad to help. Unfortunately the Kinetic configurator is quite buggy. I am working on several configurators for clients and routinely I open support calls. This is my third one in the last week.

Ironically, the reason we started working on the Kinetic configurator is that 2024.2.4 broke a couple of our Classic configurators. That issue is apparently resolved in 2024.2.8 and is documented elsewhere on Epiusers.

Overall, it hasn’t been too bad on the Kinetic configurator. There are user interface issues in the Designer but the end product is working okay so far in testing.

Hopefully we get some resolution on this issue from the support case. For now, we’ll just work around it with delimited strings.

1 Like

Jim, do you know if this issue got resolved or assigned a PRB?

Thanks very much.

There is a case CS0004750009, they asked me to check to see if it is still an issue, not sure if they think it was fixed as part of something or ?? I will be checking today to confirm if still a problem. The Kinetic configruator is still not ready for prime time in my mind. They changed how double/decimal are treated between methods and I have a configurator that will need major surgery to resolve the issue.

1 Like