April 19, 2013

Creating Vendors through X++ in AX 2012- PART I

Creating Vendors through X++ in AX 2012- PART I

--Create party for the vendor--

public void TheAxaptaCreateParty(VendorRequestCreate          _vendorRequestCreate)
{
    ;
if(_vendorRequestCreate.DirPartyType        == DirPartyBaseType::Person)
    {
        dirPerson.Name                          = _vendorRequestCreate.VendorName;
        dirPerson.NameAlias                     = _vendorRequestCreate.FirstName;
        dirPerson.NameSequence                  = dirNameSequence::find('First Last').RecId;
        dirPerson.insert();
        dirPersonName.FirstName                 = _vendorRequestCreate.FirstName;
        dirPersonName.MiddleName                = _vendorRequestCreate.MiddleName;
        dirPersonName.LastName                  = _vendorRequestCreate.LastName;
        dirPersonName.ValidFrom                 = DateTimeUtil::newDateTime(systemDateGet(),str2time ('00:00:00'),DateTimeUtil::getUserPreferredTimeZone());
        dirPersonName.ValidTo                   = DateTimeUtil::maxValue();
        dirPersonName.Person                    = dirPerson.RecId;
        dirPersonName.insert();
        dirParty                                = new DirParty(dirPerson);
    }
else
    {
        dirOrganisation.Name                    = _vendorRequestCreate.VendorName;
        dirOrganisation.NameAlias               = _vendorRequestCreate.FirstName;
        dirOrganisation.LanguageId              = 'EN-US';
        dirOrganisation.KnownAs                 = _vendorRequestCreate.VendorName;
        dirOrganisation.PhoneticName            = _vendorRequestCreate.VendorName;
        dirOrganisation.insert();
        dirParty                                = new DirParty(dirOrganisation);
    }
}


-Harry

No comments:

Post a Comment

Thanks