最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

在X ++中创建联系信息 / Create contact information in X++

网络文摘 William 32浏览 0评论

Purpose:

The purpose of this blog post is to demonstrate how to create contact information in X++

Product:

Dynamics AX 2012

Description:

The code create contact information with purpose “Collection” on the customer record.

Code:

static void MAKCustContactCreate(Args _args)
{
    #define.LocationRoleName('Collection')

    CustTable                  custTable;
    DirPartyTable              dirPartyTable;
    LogisticsElectronicAddress logisticsElectronicAddress;
    LogisticsLocationRole      locationRole;
    Map                        locationRoleMap;
    container                  locationRoleCon;
    ;

    custTable = CustTable::find('C000115');
    dirPartyTable = DirPartyTable::findRec(custTable.Party);

    if (!dirPartyTable.existElectronicAddrbyRole(#LocationRoleName))
    {
        locationRoleMap = new Map(Types::Int64, Types::String);
        locationRole = LogisticsLocationRole::findByName(#LocationRoleName);

        if (locationRole)
        {
            locationRoleMap.insert(locationRole.RecId, locationRole.description());
            locationRoleCon = map2Con(locationRoleMap);

            ttsBegin;
            logisticsElectronicAddress.Type = LogisticsElectronicAddressMethodType::Email;
            logisticsElectronicAddress.Locator = 'testUserAccount2@domain.com';
            logisticsElectronicAddress.Location = DirPartyLocation::findOrCreate(CustTable.Party, 0).Location;
            logisticsElectronicAddress = LogisticsElectronicAddress::findOrCreate(logisticsElectronicAddress);
            logisticsElectronicAddress = LogisticsElectronicAddress::findRecId(logisticsElectronicAddress.RecId, true);
            logisticsElectronicAddress.Description = "Email from X++";
            logisticsElectronicAddress.IsPrimary = NoYes::No;
            logisticsElectronicAddress.update();
            LogisticsEntityLocationRoleMap::createEntityLocationRoles(tableNum(LogisticsElectronicAddressRole), logisticsElectronicAddress.RecId, conPeek(locationRoleCon, 1), true);
            ttsCommit;

            info(strFmt("Created/updated email address %1 for customer %2.", logisticsElectronicAddress.Locator, custTable.AccountNum));
        }
    }
}
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址