Oct 5, 2016

How to : Create vendor or customer contact information through X++ (X++로 벤더 또는 고객 담당자 정보 생성하기)

static void create_CustVendContactInfo(LogisticsElectronicAddressMethodType _Type,
                                       TableId                              _TableId,
                                       AccountNum                           _AccountNum,
                                       Description                          _LocationName,
                                       LogisticsElectronicAddressLocator    _Locator,
                                       PhoneLocal                           _LocatorExt)
{
    CustTable                       _CustTable;
    VendTable                       _VendTable;
   
    DirPartyTable                   _DirPartyTable;
    DirParty                        _DirParty;
    LogisticsLocation               _LogisticsLocation;
    LogisticsElectronicAddress      _LogisticsElectronicAddress;
   
    switch (tableId2name(_TableId))
    {
        case "CustTable":
            select firstOnly _CustTable
            index hint AccountIdx
            join _DirPartyTable
            where _CustTable.AccountNum == _AccountNum
            && _DirPartyTable.RecId == _CustTable.Party;
            break;
        case "VendTable":
            select firstOnly _VendTable
            index hint AccountIdx
            join _DirPartyTable
            where _VendTable.AccountNum == _AccountNum
            && _DirPartyTable.RecId == _VendTable.Party;
            break;
    }
   
    _LogisticsLocation = LogisticsLocation::create(_LocationName,
                                                    NoYes::No);

    DirParty::addLocation(  _DirPartyTable.RecId,
                            _LogisticsLocation.RecId,
                            false,
                            true,
                            false);

    _LogisticsElectronicAddress.clear();
    _LogisticsElectronicAddress.initValue();
    _LogisticsElectronicAddress.Description             =           _LocationName;
    _LogisticsElectronicAddress.Location                =           _LogisticsLocation.RecId;
    _LogisticsElectronicAddress.Type                    =           _Type;
    _LogisticsElectronicAddress.Locator                 =           _Locator;
    _LogisticsElectronicAddress.LocatorExtension        =           _LocatorExt ;
    //_LogisticsElectronicAddress.ValidFrom = DateTimeUtil::utcNow();
    //_LogisticsElectronicAddress.ValidTo = DateTimeUtil::maxValue();

    if (_LogisticsElectronicAddress.validateWrite())
    {
        _LogisticsElectronicAddress.insert();
    }
}

No comments:

Post a Comment