Showing posts with label CreateVendor. Show all posts
Showing posts with label CreateVendor. Show all posts

Create Vendor using X++ D365FO & AX-2012


Create Vendor using X++ D365FO & AX-2012



Following Code will help you to create Vendor using X++

For Default Dimension please check Link

public class VendorHelper
{

 

   

  
        private void new()
        {
        }

        public static VendorHelper construct()
        {
            return new VendorHelper();
        }

        public void createVendor()
        {
            VendTable                    vendTable;
            NumberSeq                    numberSeq;
            Name                         name ='Systems Limited Karachi, Pakistan';

            DirParty                        dirParty;
            DirPartyPostalAddressView       dirPartyPostalAddressView;
            DirPartyContactInfoView         dirPartyContactInfo;
            ;
            container      conAttribute=["BusinessUnit","CostCenter","Department"];
            container      conAttributeValue=["001","007","022"];
            /* Marks the beginning of a transaction.
            Necessary to utilize the method numRefCustAccount() */
            ttsBegin;
            vendTable.initValue();

            try
{
                //vendTable
            //numberSeq               = NumberSeq::newGetNum(VendParameters::numRefVendAccount())
                // vendTable.AccountNum    = numberSeq.num();
                vendTable.AccountNum    = "Vend-00099";
                vendTable.VendGroup     ='30';
                vendTable.Currency      ='USD';
                vendTable.PaymTermId    ='Net10';
                vendTable.PaymMode      ='CHECK';
                vendTable.DefaultDimension=DefaultDimesnionHelper::createDefaultDimension(conAttribute,conAttributeValue);
                vendTable.insert();

                //DirParty

                /* Creates a new instance of the DirParty class from an address book entity
                that is represented by the custTable parameter. */
                dirParty = DirParty::constructFromCommon(vendTable);

                dirPartyPostalAddressView.LocationName      ='Systems limited Karachi, Pakistan ';
                dirPartyPostalAddressView.City              ='Karachi';
                dirPartyPostalAddressView.Street            ='Shah-re-faisal alcope-house';
                dirPartyPostalAddressView.StreetNumber      ='18';
                dirPartyPostalAddressView.CountryRegionId   ='PAK';
                dirPartyPostalAddressView.State             ='Sindh';
                dirPartyPostalAddressView.IsPrimary             = NoYes::Yes;
                // Fill address
                dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);


                dirPartyContactInfo.LocationName    ='Email Address';
                dirPartyContactInfo.Locator         ='ShaikhSohailHussain@gmail.com';
                dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Email;
                dirPartyContactInfo.IsPrimary       = NoYes::Yes;

                // Fill Contacts
                dirParty.createOrUpdateContactInfo(dirPartyContactInfo);


                dirPartyContactInfo.LocationName    ='Mobile Number';
                dirPartyContactInfo.Locator         ='923422722538';
                dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Phone;
                dirPartyContactInfo.IsPrimary       = NoYes::Yes;

                // Fill Contacts
                dirParty.createOrUpdateContactInfo(dirPartyContactInfo);

                // Marks the end of transaction.
                ttsCommit;
            }
            catch(Exception::Error)
            {
                ttsAbort;
                throw Exception::Error;
            }
        }

}

Support Faryal's Cusine


Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...