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 :
Microsoft Dynamics AX (Archived)

How can I Serialize an object array in Dynamics AX?

(0) ShareShare
ReportReport
Posted on by 150

Hi all

I can serialize an object in this way :

public class CustomerRecord implements AifXmlSerializable
{
  str customerId;
  str CustomerName;

  // Define Name Space & Root Element
  #define.CustomerNS ('http://schemas.contoso.com/samples/Customer')
  #define.CustomerRoot ('Customer')
}

void deserialize(AifXml xml)
{
  XmlTextReader xmlReader;

  ;

  xmlReader = XmlTextReader::newXml(xml);

  // turn off Whitespace handling to avoid extra reads
  xmlReader.whitespaceHandling(XmlWhitespaceHandling::None);
  xmlReader.moveToContent();
  while ((xmlReader.nodeType() != XmlNodeType::Element) && !xmlReader.eof())
  {
    xmlReader.read();
  }
  xmlReader.readStartElement3(#CustomerRoot, #CustomerNS);

  if (!xmlReader.eof() && xmlReader.isStartElement())
  {
    customerId   = xmlReader.readElementString3('CustomerId',    #CustomerNS);
    customerName  = xmlReader.readElementString3('CustomerName',   #CustomerNS);
  }

  xmlReader.readEndElement();
  xmlReader.close();
}

public AifDocumentName getRootName()
{
  return #CustomerRoot;
}

public AifXml getSchema()
{
  str schema =
    @'<?xml version="1.0"?>
    <xsd:schema xmlns="http://schemas.contoso.com/samples/Customer"
          targetNamespace="http://schemas.contoso.com/samples/Customer"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          elementFormDefault="qualified">

      <xsd:complexType name="CustomerType">
        <xsd:sequence>

          <xsd:element name="CustomerId"   type="xsd:string" />
          <xsd:element name="CustomerName"  type="xsd:string" />

        </xsd:sequence>
      </xsd:complexType>
      <xsd:element name="Customer" type="CustomerType"/>
    </xsd:schema>'

  ;

  return schema;
}

public str parmCustomerId(str _customerId = '')
{
  if (!prmisdefault(_customerId))
  {
    customerId = _customerId;
  }

  return customerId;
}

public str parmCustomerName(str _customerName = '')
{
  if (!prmisdefault(_customerName))
  {
    customerName = _customerName;
  }

  return customerName;
}

But I need to serialize a list of object.

Can anyone help or have any idea about this?

Serkan

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Denis Patrakov Profile Picture
    on at

    See AifEntityKeyList class for an example.

  • _SerkanYildirim_ Profile Picture
    150 on at

    Hi gl00mie

    This will solve my problem.

    Thank You

    Serkan

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans