AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 08.05.2012, 04:13   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
AIF: How to serialize int/real properties with 0/0.00 values via AIF outbound integration
Источник: http://blogs.msdn.com/b/aif/archive/...tegration.aspx
==============

It is a known limitation that AIF does not serialize null values in outbound XMLs. This is true for fields of data type int or real (or any EDT based on them) in Microsoft Dynamics AX. 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 few 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. The tradeoff in this case is that both inbound and outbound exchanges for the document would need to include the required field or else the service operation would throw an error.

This article demonstrates shows how to make a field mandatory at service level.

To demonstrate the outbound scenario, we are using BomBillsofMaterialsService document service already provided in Microsoft Dynamics AX and Contoso demo dataset available with product download.

Now let’s walk through this scenario

1. Import Contoso dataset

2. Register BomBillsofMaterialsService in AOT.

3. Create an outbound port. Expose BomBillsofMaterialsService.* service operations on the port.

4. Open Inventory and Warehouse Management à Common à Bills Of Materials form. This form already has AIF send API to generate outbound requests for AIF.

5. Select an item and set ‘From qty = 0.00’ on the form. Click on “Send…”and select the outbound port. This sends an outbound BomBillsofMaterialsService.find request to the AIF.

6. Run AifOutboundProcessingService and AifGatewaySendService batch jobs. For more information, see the section “Configure and start the AIF batch services” in this topic on MSDN: http://msdn.microsoft.com/en-us/library/hh352313.aspx ..

7. Check the resulting xml. The outbound xml in this case does not contain the tag ‘FromQty’ since its value is 0.00

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



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

2. Update method body as



protected void initMandatoryFieldsMap()

{

super();

this.setParmMethodAsMandatory(classNum(AxBOMVersion),methodStr(AxBOMVersion,parmFromQty));

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

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

4. Compile the method.

5. Generate Incremental IL

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

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

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









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

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












Источник: http://blogs.msdn.com/b/aif/archive/...tegration.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
Теги
aif

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Microsoft Dynamics CRM Team Blog: CRM 2011 Chart Enhancements Blog bot Dynamics CRM: Blogs 0 25.01.2012 10:11
crminthefield: How to Create a Silverlight Web Resource that Interacts with CRM 2011 Forms Blog bot Dynamics CRM: Blogs 0 24.06.2011 04:17
Падает AOS MS DAX 2009 SP1 RU6 Daiver DAX: Администрирование 21 14.02.2011 09:59
daxsol: Axapta Kernel Functions Blog bot DAX Blogs 1 16.05.2009 19:22
при построении перекрёстных ссылок выдаётся сообщение об ошибках mmmax DAX: Программирование 10 21.01.2005 12:42

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 20:53.