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:
Here is the code to do so:
1: //Converts private addresses to public addresses
2: static void 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 dirPartyAddressRelationshipMapping28: 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: }