Показать сообщение отдельно
Старый 07.03.2009, 00:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,491 / 846 (79) +++++++
Регистрация: 28.10.2006
axStart: Check if the table field is mapped.
Источник: http://axstart.spaces.live.com/Blog/...C0A0!482.entry
==============


Let’s have a look at the next scenario:
•             I have added a new field on my table map.
•             This new field not used on al the tables that use this table map.
•             I use this mapped field inside my table method.
 
If you don’t check it, you get an error about field ID is zero and you are not in the mood to check for all places where this method is use. And you don't want to change AX on all those places
 
Solution:
TreeNode::findNode(#TableMapsPath+'\\Map\\Mappings\\'+tableid2name(this.TableId)+'\\Field');
If the TreeNode exist the field is not mapped.
 
Example:
 
public static void initMapFromMap(AddressMap _toAddress,
                                  AddressMap _fromAddress)
{
   #AOT
    _toAddress.Address          = _fromAddress.Address;
    _toAddress.Street           = _fromAddress.Street;
    _toAddress.ZipCode          = _fromAddress.ZipCode;
    _toAddress.City             = _fromAddress.City;
    _toAddress.County           = _fromAddress.County;
    _toAddress.State            = _fromAddress.State;
    _toAddress.CountryRegionId  = _fromAddress.CountryRegionId;
    if(TreeNode::findNode(#TableMapsPath+'\\AddressMap\\Mappings\\'+tableid2name(_toAddress.TableId)+'\\Telex') &&
       TreeNode::findNode(#TableMapsPath+'\\AddressMap\\Mappings\\'+tableid2name(_fromAddress.TableId)+'\\Telex'))
           _toAddress.Telex            = _fromAddress.Telex;
}
 


Источник: http://axstart.spaces.live.com/Blog/...C0A0!482.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.