Wednesday, February 20, 2013

Create contact by code


static void ContactCreate(Args _args)
{
    DirPartyRecId               party;
    DirPartyContactInfoView     contactView;
    DirParty                    dirParty;
    LogisticsLocationRoleRecId  role;
    LogisticsLocationRole       LogisticsLocationRole;

    party = CustTable::find('CUSTOMER ID').Party;

    contactView.LocationName = "Name";
    contactView.Locator      = "www.microsoft.com";
    contactView.Type         = LogisticsElectronicAddressMethodType::URL;
    contactView.Party        = party;
    contactView.IsPrimary    = false;
    contactView.LocatorExtension = "";

    role = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Business).RecId;
    dirParty = dirParty::constructFromPartyRecId(party);
    dirParty.createOrUpdateContactInfo(contactView,[role]);

}