RSS

How to resolve int/real with 0/0.00 values via AIF outbound integration with external application

04 Oct

there is known issue with Dynamics Ax AIF Does not serialize the integer or Real values like when table fields having values 0/0.00. it will always return the null values and does not allow to update these values.

Scenario 1.

Table XYZ

Fields

X1(String),X2(Int),X3(Real) having values

X1=Deepak ,X2=0,X3=0.0

when you will try to execute the  AIF find operation it will return the data set fields values “Deepak”,Null,Null respectively fields X1,X2,X3. it will not allow to update the null values while execution of AIF Update Operation.

Scenario 2

X1=Deepak ,X2=2,X3=2.0

when you will try to execute the AIF find operation it will return the data set fields values “Deepak”,2,2.0 respectively fields X1,X2,X3. it will allow to update with null values as well as other values while execution of AIF Update Operation.

but when you will update these values with null or zero then it wont allow you update the values and got stuck in first scenario.

 

this is a known limitation that AIF does not serialize null values in outbound XMLs. If the outbound document has int or real fields with value 0 or 0.0, they would not appear in the outbound XML generated by AIF. The reason is that AX does not have null values so default values (0 for int, 0.00 for real, ‘’ for strings) for each type are treated as nulls and are not serialized by outbound operations.

 

There are some workarounds for this limitation. If you want a field to be serialized irrespective of its value, you need to make it a “required” field. This can be done in two ways:

– Make field mandatory at table level ie. In AOT , set the field property ‘Mandatory’ to Yes.

– Make the field mandatory at service level.

Making a field mandatory at the table level affects all the consumers of the table such as forms. The second way is less intrusive since it only affects services stack.

 

This article demonstrates shows how to make a field mandatory at service level.To demonstrate this i have created a table named CrmTable having fields (SanctionLoad(Real),PeakLoad(Real),Multiplyfactor(Real),Account(String),qty(Int)), and run the Application Integration Framework wizard.

Now we are  using CrmTableQueryService document service with operations find,Create,Update.

 

Now we will try to consume this web service though .Net Application,whenever we will  try to run the first scenario it will through the error because the xml file does not contains the  Real and Interger values fields.we can Check the resulting xml in Basic->Periodic->AIF->Document Schema. The outbound xml in this case does not contain the tag ‘Sanction Load,Peak Load,Multiply factor, Qty  since its value is 0.00/0.

As you would have observed that the ‘the fields property are missing from the outbound xml. Let’s apply workaround #2 – of making fields mandatory for CrmTableQueryService by following steps:

 

1. Open the document class for CrmTableQueryService service – AxdCrmQueryTable . Override method initMandatoryFieldsMap() from the AxdBase in AxdCrmQueryTable class

2. Update method body as

protected void initMandatoryFieldsMap()

 

 {

 

 super();

 

 this.setParmMethodAsMandatory(classNum(AXCrmTable),methodStr(AxCrmTable,parmSanctionLoad));

 

 }

For more information about the initMandatoryFieldsMap method, see http://msdn.microsoft.com/en-us/library/axdbase.initmandatoryfieldsmap.aspx .

3. Here AxCrmTable is the AxBC class for the table that contains the field and parmSanctionLoad is the name of the field parm method.

4. Compile the method.

5. Register the service again by right clicking the service node in AOT and selecting ‘Register Service’

6. Stop and restart the AOS to flush all caches.

7. Click on View Schema button on Document Data Policies form for the outbound port. The updated schema now shows ‘Sanction Load’ as a mandatory field.

image

 

9. Send another request to the outbound port with Sanction Load= 0.00.

 

10. Open the outbound xml and  this time you will see the Sanction Load property in the output xml.

 

image

 

 

Happy Daxing Open-mouthed smile

Advertisements
 

Tags: ,

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

 
%d bloggers like this: