Passing a list or array from Arden MLM to C#

388 Views Asked by At

I'm having a pretty hard time finding documentation on Lists and Arrays in Arden MLM.

I am trying to pass a list of 4 digit numbers from Arden using ObjectsPlus to a C# DLL that can take that list as an argument and do what the function is designed for.

Here is what I have in Arden MLM but does not work as I get the .net error "Object reference not set to an instance of an object"

Here is the MLM:

list_id_object       := OBJECT [id_list_holder];
id_list              := new list_id_object with "1154", "1155", "1158"; 

try
    send_alert_start := new net_object 'Webservices';
    result := call send_alert_start.'pageToMultipleIds' with
        ((sender_name as string) as 'String'),
        ((sender_message as string) as 'String'),
        ((list_id_object as list) as 'List<Int32>');
endtry;
catch Exception ex
    error_occured := true;
    error_message := "Error message here\n" || ex.Message || "\n\n";
endcatch;

And here is the C# method that receives that list:

public string testMethod(string sender_name, string sender_message, List<Int32> IdToPage)
    {
        try
            {
                testMethod2(sender_name, sender_message, IdToPage);
                return "Success";
            }
            catch(WebException e)
            {
                return e.ToString();
            }
    }
2

There are 2 best solutions below

0
On BEST ANSWER

This is written for Allscripts SCM but it should show how to build a List. Unfortunately you have to create a standard Arden list and then loop through it and add each item to the List.

std_include_libs := mlm'std_include_libs';
include std_include_libs;

id_list := 1154, 1155, 1158;

try; 
    using "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
    using namespace "System.Collections.Generic";
    idList := new net_object 'List<Int32>';
    for i in id_list do
        void := call idList.'Add' with i as 'Int32';
    enddo;

    send_alert_start := new net_object 'Webservices';
    result := call send_alert_start.'pageToMultipleIds' with    ((sender_name as string) as 'String'),
                                                                ((sender_message as string) as 'String'),
                                                                idList;
endtry;
catch Exception ex;
    error_occurred := true;
    error_message := "Error message here\n" || ex.Message || "\n\n";
endcatch;
0
On

see change below.

((list_id_object as list) as 'List<Int32>');

changed to

((list_id as list) as 'List<Int32>');

.

list_id_object       := OBJECT [id_list_holder];
id_list              := new list_id_object with "1154", "1155", "1158"; 

try
    send_alert_start := new net_object 'Webservices';
    result := call send_alert_start.'pageToMultipleIds' with
        ((sender_name as string) as 'String'),
        ((sender_message as string) as 'String'),
        ((list_id as list) as 'List<Int32>');
endtry;
catch Exception ex
    error_occured := true;
    error_message := "Error message here\n" || ex.Message || "\n\n";
endcatch;