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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 07.04.2011, 02:15   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
Rahul Sharma: Convert Dynamics AX Entity Private Address into Public GAB Address
Источник: http://feedproxy.google.com/~r/Rahul...y-private.html
==============

In this article, we will see how to convert Customer / Vendor's private addresses into public GAB addresses. If you try to do it manually by clicking the public check box on a private address then it will just not allow you to do it.

Here is the code to do so:



X++:
   1:  //Converts private addresses to public addresses
   2:  static void CSA_ConvertPrivateAddressToPublic(Args _args)
   3:  {
   4:      #OCCRetryCount
   5:      DirPartyAddressRelationshipMapping  dirPartyAddressRelationshipMapping;
   6:      Address                             address, address2;
   7:      DirParty                            dirParty;
   8:      DirPartyTable                       dirPartyTable;
   9:   
  10:      void convertAddress()
  11:      {
  12:          ;
  13:          address.clear();
  14:          address = Address::findRecId(address2.RecId, true);
  15:   
  16:          //dir party associated with the entity
  17:          dirParty = DirParty::constructFromCommon(address);
  18:   
  19:          dirPartyTable = DirPartyTable::find(dirParty.parmPartyId());
  20:   
  21:          //update these values so that this private address now belongs to the party of the entity
  22:          address.AddrTableId = dirPartyTable.TableId;
  23:          address.AddrRecId   = dirPartyTable.RecId;
  24:          address.update();
  25:   
  26:          //check if GAB mapping has been created
  27:          select dirPartyAddressRelationshipMapping
  28:              where dirPartyAddressRelationshipMapping.AddressRecId == address.RecId &&
  29:                    dirPartyAddressRelationshipMapping.RefCompanyId == address.dataAreaId;
  30:   
  31:          //create GAB mapping if does not exist
  32:          if (!dirPartyAddressRelationshipMapping.RecId)
  33:              DirPartyAddress::insertPartyAddressRelationship(address);
  34:      }
  35:      ;
  36:   
  37:      //select private customer and vendor addresses
  38:      while select address2
  39:          where address2.AddrTableId == tablenum(CustTable) ||
  40:                address2.AddrTableId == tablenum(VendTable)
  41:      {
  42:          try
  43:          {
  44:              ttsbegin;
  45:              convertAddress();
  46:              ttscommit;
  47:          }
  48:          catch (Exception::Deadlock)
  49:          {
  50:              if (xSession::currentRetryCount() >= #RetryNum)
  51:              {
  52:                  throw Exception::Deadlock;
  53:              }
  54:              else
  55:              {
  56:                  retry;
  57:              }
  58:          }
  59:          catch (Exception::UpdateConflict)
  60:          {
  61:              if (appl.ttsLevel() == 0)
  62:              {
  63:                  if (xSession::currentRetryCount() >= #RetryNum)
  64:                  {
  65:                      throw Exception::UpdateConflictNotRecovered;
  66:                  }
  67:                  else
  68:                  {
  69:                      retry;
  70:                  }
  71:              }
  72:              else
  73:              {
  74:                  throw Exception::UpdateConflict;
  75:              }
  76:          }
  77:          catch
  78:          {
  79:              error(strfmt("Conversion failed for address record id %1 in %2 company. \n Correct it and resume conversion again.", address2.RecId, address2.dataAreaId));
  80:          }
  81:      }
  82:   
  83:  }

Join this blog if you liked this post and feel free to post your comment / feedback / queries.
www.RahulSharma.in






Источник: http://feedproxy.google.com/~r/Rahul...y-private.html

Последний раз редактировалось Poleax; 07.04.2011 в 09:23.
Теги
глобальная адресная книга, address

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axinthefield: Dynamics AX Event IDs Blog bot DAX Blogs 0 01.03.2011 22:11
daxdilip: Whats New in Dynamics AX 2012 (A brief extract from the recently held Tech Conf.) Blog bot DAX Blogs 7 31.01.2011 12:35
dynamics-ax: Official Details about Dynamics AX '6' released, including comments from Microsofts Kees Hertogh Blog bot DAX Blogs 0 11.01.2011 05:22
Sample Design Patterns: Upgrade to Microsoft Dynamics AX 2009 and issues with the global address book Blog bot DAX Blogs 0 21.12.2010 11:11
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 16:54.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.