Showing posts with label AX7. Show all posts
Showing posts with label AX7. Show all posts

How to get Vendor's or Customer's Contact Person's Contact Information




How to get  Vendor's or Customer's  Contact Person's Contact Information

Via below code you can get the Vendor/Customer contact person and their complete contact information.


class SLD_DemoInstance
{





   
    public static void main(Args _args)
    {

        ContactPerson            contactPerson;
        DirPartyTable       dirPartyTable;
        LogisticsElectronicAddress      address;
   
        DirPartyLocation        partylocation;
   
   
        RecId _refRecId= VendTable::find("S00038").Party;
        while select contactPerson
         where contactPerson.ContactForParty==_refRecId
        join dirPartyTable
        where dirPartyTable.RecId==contactPerson.Party
        join partylocation
        where partylocation.Party==contactPerson.Party
        outer join address
        where address.Location==partylocation.Location
      
        {
       
            info(strFmt("%1, %2, %3",contactPerson.ContactPersonId,contactPerson.personName(),address.Locator));
        }
    }


}




Item Attribute



Item Attribute
Query relation to getting Item attributes.




InventTable                                             objinventTable;
EcoResProduct                                        objecoResProduct;
EcoResValue                                           objecoResValue;
EcoResAttributeValue                             objecoResAttributeValue;
EcoResAttribute                                      objecoResAttribute;
EcoResInstanceValue                              objecoResInstanceValue;
EcoResAttributeType                              objecoResAttributeType;
EcoResProductInstanceValue                 objecoResProductInstanceValue;
int i = 0;
;
while select objecoResAttributeValue
join objecoResAttribute
where objecoResAttributeValue.Attribute == objecoResAttribute.RecId
join objecoResAttributeType
where objecoResAttribute.AttributeType == objecoResAttributeType.RecId
join objecoResInstanceValue
where objecoResAttributeValue.InstanceValue == objecoResInstanceValue.RecId
join objecoResValue
where ecoResAttributevalue.Value == objecoResValue.RecId
join objecoResProductInstanceValue
where objecoResInstanceValue.RecId == objecoResProductInstanceValue.RecId
join objecoResProduct
where objecoResProduct.RecId == objecoResProductInstanceValue.Product
join objinventTable
where objinventTable.Product == objecoResProduct.RecId
&& objinventTable.itemid='D0001'
{
     info(strFmt("%1 %2",objecoResProduct.DisplayProductNumber,objecoResAttribute.Name));
}

Product Receipt validation in Extension using COC D365FO



Product Receipt validation in Extension using COC D365FO



Using following code you can perform custom validation on product receipt using COC


[ExtensionOf(classstr(PurchPackingSlipJournalCreate))]
final class SLD_PurchPackingSlipJournalCreate_Extension
{

    protected boolean check()
    {
      
        PurchParameters     purchParam=PurchParameters::find();
        boolean flag=    next check();

            flag= flag && this.validatePackingSlip(flag);
      
        return flag;
    }

    public boolean validatePackingSlip(boolean flag)
    {
        if(flag && this.purchParmUpdate.DocumentStatus==DocumentStatus::PackingSlip)
        {
        
 

        }
        return flag;
    }

}

List of Tables X++ D365FO, AX7 and AX2012


List of Tables X++ D365FO, AX7 and AX2012




       public void run()
    {
        Dictionary dict = new Dictionary();
        DictTable dictTable;


        SysDictTable sysDictTable;
        for (int i=1; i<=dict.tableCnt(); i++)
        {

            sysDictTable=new SysDictTable(dict.tableCnt2Id(i));


        }
    }

Number Sequence D365FO


Number Sequence D365FO 




Number sequences are used to generate readable, unique identifiers for master data records and transaction records that require identifiers.
In this demo, I am going to create a new number sequence for customer group form.

Create a new class with name NumberSeqModuleCustomer_CustGroup that extends the NumberSeqModuleCustomer class and then create the method loadNumberSequence.

Reference Screenshot:


Now create extension class of CustParameters_Extension and add your custom method to find number sequence..

Reference Screenshot:



Now create Run able class to initialize the  number sequence...


Reference Screenshot:


Perform build & Sync and load the number sequence. In my demo i have place Action menu item of executable class on following navigation.


Reference Screenshot:


Now Navigate to organization administration > Number sequence and generate number sequence.

 Reference Screenshot:



Next Step to Navigate to Account receivable parameter setup to veriy our newly create number sequence loaded successfully or not...  You have to verify on your desire number sequence module.




Next step to override CustGroup form data source Initial value event.


 Reference Screenshot:



Perform build & Sync and verify on your cust group.. for me its working fine please have look on below screenshot.


Please feel free to contact me if you are facing any issue during implementation of above blog.

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;
            }
        }

}

Default Dimension D365FO AX-2012


Default Dimension D365FO AX-2012





Following Code will help you to create Default Dimension using X++



Default Dimension Class 


public class DefaultDimesnionHelper
{

    public static DimensionDefault createDefaultDimension(container conAttribute,container attributeValue)
    {
        DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
        DimensionDefault                    result;
  
        int                     i;
        DimensionAttribute      dimensionAttribute;
        DimensionAttributeValue dimensionAttributeValue;
  
        // Note that "Item" is not one of the default dimension,
        // but DimensionAttributeValueSetStorage will handle it gracefully
        container               conAttr = conAttribute;
        container               conValue = attributeValue;
        str                     dimValue;
  
        for (i = 1; i <= conLen(conAttr); i++)
        {
            dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
      
            if (dimensionAttribute.RecId == 0)
            {
                continue;
            }
      
            dimValue = conPeek(conValue,i);
      
            if (dimValue != "")
            {
                // The last parameter is "true". A dimensionAttributeValue record will be created if not found.
                dimensionAttributeValue =
                    dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
          
                // Add the dimensionAttibuteValue to the default dimension
                valueSetStorage.addItem(dimensionAttributeValue);
            }
        }
  
        result = valueSetStorage.save();
        return result;
    }


}

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...