AX 4.0 Send GUID in AIF document

I’ve noticed a a bug in AX 4.0 (K/A: 4.0.2501.116) AIF implementation when using a table field type GUID. Unfortunately the generated XSD schema referred to the field type as Int64 instead of GUID. The sent XML of course contained an GUID String {00000000-1234-5678-9101-000000000000}. My C# .NET client reported an error because the received value was not a valid Int64.
I solved the problem by editing AxdBaseGenerateXSD.addGuid() method
protected void addGuid(
SysDictType dt,
XmlSchemaSimpleTypeRestriction restriction
)
{;
/*  restriction.baseTypeName(
XmlQualifiedName::construct(
this.addInt64Type(),
targetNameSpace)); */
restriction.baseTypeName (XmlQualifiedName::construct(
this.addGuidType(),
targetNameSpace));
}
As result the generated XSD schema contained the correct GUID definition
<xs:simpleType name=”AxdExtType_MyGUID“>
<xs:annotation>
<xs:documentation xml:lang=”DE-AT“>A Guid field</xs:documentation>
</xs:annotation>
<xs:restriction base=”AxdType_GUID” />
</xs:simpleType>

<xs:simpleType name=”AxdType_GUID“>
<xs:restriction base=”xs:string“>
<xs:minLength value=”38” />
<xs:maxLength value=”38” />
<xs:pattern
value=”({[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}})” />
</xs:restriction>
</xs:simpleType>

About erpcoder
Azure Cloud Architect and Dynamics 365 enthusiast working in Research & Development for InsideAx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: