web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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!

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    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.

  • José Quintero Profile Picture
    160 on at

    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
    237,948 Most Valuable Professional on at

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

    array.SetValue(formaPago, 0);

  • José Quintero Profile Picture
    160 on at

    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

  • Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    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

    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

  • Suggested answer
    Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    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

    You are very right!

    Thanks!

  • Verified answer
    Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    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.

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

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans