Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Ax 2009 and c# pass data

(0) ShareShare
ReportReport
Posted on by 160

Hi!:

I am having an issue with Ax 2009 and C#.

Passing simple string values is not a problem.

But, when I need to pass a data type List, Ax "don't see"

C# method.

For example:

The method in C# is the following:

using System.Xml.Serialization;

[XmlArray(IsNullable = true)]
[XmlArrayItem("formaPago")]
public FormaPago[] listaFormaPago
{
    get
    {
        return listaFormaPagoField;
    }
    set
    {
        listaFormaPagoField = value;
    }
}

In Ax, how I pass this data?.

 totalesSubTotales.set_listaFormaPago();

the parameter between parenthesis show me in Ax:

void set _ListaFormaPago(FormaPago[] value)

Regards!

  • Verified answer
    Martin Dráb Profile Picture
    234,712 Most Valuable Professional on at
    RE: Ax 2009 and c# pass data

    If your question has been answered, please don't forget to verify the answer. It's done by clicking Did this answer your question? > Yes on the reply (or replies) answering the question.

  • José Quintero Profile Picture
    160 on at
    RE: Ax 2009 and c# pass data

    You are very right!

    Thanks!

  • Suggested answer
    Martin Dráb Profile Picture
    234,712 Most Valuable Professional on at
    RE: Ax 2009 and c# pass data

    I see no (5) in your code. Do you mean (1)?

    Sorry, the right syntax seems to be FormaPago[1]().

  • José Quintero Profile Picture
    160 on at
    RE: Ax 2009 and c# pass data

    Hello:

    Morph X put in redline when I add (5) to AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[]

    in the initialization of array in declaration.

       AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[] array   = new  AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[](1);

    Syntax error show me.

    I am in Ax 2009.

    Regards

  • Martin Dráb Profile Picture
    234,712 Most Valuable Professional on at
    RE: Ax 2009 and c# pass data

    I disagree - AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[ isn't and array of strings. It's an array of AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago.

    Where exactly do you get the syntax error?

    Do I understand correctly that this works:

    AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[] array;

    but this fails to compile?

    AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[] array = AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[](1);

  • José Quintero Profile Picture
    160 on at
    RE: Ax 2009 and c# pass data

    Hi Martin!:

    Well, I use your solution.

    I declare an array of type String like following:

      AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[] array;

    No problem, It accepts it.

    When I use the method in C# it accepts the array declarated before.

       totalesSubTotales.set_listaFormaPago(array);

    Before that I made the set in the array:

       array.SetValue(formaPago,0);

    But, I have a question, the unique part that does not work

    is this:

    TheNamespace.FormaPago[] array = TheNamespace.FormaPago[](5);

       AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[] array   = AXV5ElectronicInvoice.TfhkaPaWebService.FormaPago[](1);

    The Ax send me error "syntax error".

    Regards

  • Suggested answer
    Martin Dráb Profile Picture
    234,712 Most Valuable Professional on at
    RE: Ax 2009 and c# pass data

    This adds formaPago object to the array as the first element (index 0):

    array.SetValue(formaPago, 0);

  • José Quintero Profile Picture
    160 on at
    RE: Ax 2009 and c# pass data

    Hi Martin!:

    Thanks for your prompt answer.

    Yes it is. You are right.

    It is an array of objects for "FormaPago".

    I am setting the class FormaPago in Ax no problem with this:

       formaPago.set_formaPagoFact("01");

       formaPago.set_valorCuotaPagada(strLRTrim(num2Str(abs(custInvoiceJour.InvoiceAmount),11,2,0,0)));

       formaPago.set_descFormaPago("");

    But, before to pass to totalesSubTotales.set_listaFormaPago()

    Do I need to pass formaPago object to an Array?

    How I do that in Ax 2009?.

    Regards.

  • Suggested answer
    Martin Dráb Profile Picture
    234,712 Most Valuable Professional on at
    RE: Ax 2009 and c# pass data

    There is no list - it's an array of FormaPago objects. You should be able to create it in this way:

    TheNamespace.FormaPago[] array = TheNamespace.FormaPago[](5);

    This creates an empty array for five elements.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 565

#2
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2025 Season 1

Product updates

Dynamics 365 release plans