Posts

Showing posts from April, 2020

How to Import Records from Excel Using X++ Code in D365FO

  How to Import Records from Excel Using X++ Code in D365FO   Include the below namespace in X++ code it will requires to import Excel. Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange;   In addition to the basic reference, include (Directory and DirectoryUpgrade Packages) X++ Code: Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange; class ReadExcel {   public static void main(Args _args)    {     Int id;     Str Name;      System.IO.Stream stream;       ExcelSpreadsheetName sheet;              FileUploadBuild fileUpload,fileUploadBuild;       DialogGroup dialogUploadGroup;       FormBuildControl formBuildControl;       Dialog dialog=new Dialog("Excel Import using dialog");       dialogUploadGroup=dialog.addGroup("@SYS54759");       formBuildControl=dialog.formBuildDesign().control(dialogUploadGroup.name());    

Difference between Primary & Cluster index AX

Primary index:  It works on unique indexes. The data should be unique and not null. Retrieve data from the database. Clustered Index:  Clustered Index. A clustered index defines the order in which data is physically stored in a table. Table data can be sorted in only way, therefore, there can be only one clustered index per table. In SQL Server, the primary key constraint automatically creates a clustered index on that particular column It works on unique and non-unique indexes. Retrieve data from the AOS. The advantages of having a cluster index are as follows: Search results are quicker when records are retrieved by the cluster index, especially if records are retrieved sequentially along the index.   Other indexes that use fields that are a part of the cluster index might use less data space.  Fewer files in the database; data is clustered in the same file as the clustering index. This reduces the space used on the disk and in the cache. The disadvantage

Validate special characters in X++

It done after writing code in table  validateWrite  method public boolean validateWrite() {      boolean ret;      TextBuffer txt = new TextBuffer()      ret = super();      txt.setText(this.name);      txt.regularExpressions(true);    if (txt.find("^[A-Z 0-9]+$"))      {          ret = true;    }      else    {          this.name="";          throw error(" Conatin the Special Character");      }    return ret;   }

X++ Code validate the Email ID

X++ Code validate the email id: static void validateEmailID(Args _args) {        Str     email;     Str     MatchEmailPattern =@"\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b";     System.Text.RegularExpressions.Match myMatch;        ;     email = " ABCXYZ@gmail.com ";     myMatch = System.Text.RegularExpressions.Regex::Match(email, MatchEmailPattern);     if (myMatch.get_Success())         info(strFmt("%1 is an valid email id ", email));     else        info(strFmt("%1 is not an valid email id ", email)); }

CREATE AND POST PRODUCTION ROUTE JOURNAL USING X++

CREATE AND POST PRODUCTION  ROUTE JOURNAL   IN X++ static void createRouteCardJournal(Args _args) {     ProdJournalTable                      prodJournalTable;     ProdJournalRoute                     prodJournalRoute;     ProdRoute                               prodRoute;     ProdId                                     prodId     = 'ProdNo';     OprNum                                  oprNum   = 20;     RouteOprId                              routeOprId;     ProdJournalCheckPostRoute     prodJournalCheckPostRoute;     select firstonly prodRoute                 where prodRoute.ProdId == prodId  && prodRoute.OprNum == oprNum;     prodJournalTable.clear();     prodJournalTable.initValue();     prodJournalTable.JournalType            = prodjournaltype::RouteCard;     prodJournalTable.ProdId                     = prodId;     prodJournalTable.JournalNameId       = ProdParametersDim::findDefault().RouteJournalNameId;     prodJournalT

Event handler in D365 FO

Event handler in D365 FO: Table event handler: We need to add a new class to write the event handler methods. Once the class is created we need to declare the attribute for purpose of the class ExtensionOf( tableStr ( TableName ))] ValidateField:   // Table Dataeventhandler - ValidateField  [DataEventHandler( tableStr ( TableName ),  DataEventType ::ValidatedField)]   public   static   void  TableName_onValidatedField( Common  sender,  DataEventArgs  e)  {        ValidateFieldEventArgs   event   = e  as   ValidateFieldEventArgs  ;        TableName  buffTable             = sender  as  TableName;        boolean  result                  = event.parmValidateResult();  }  // Table-Posteventhandler for validateField   [PostHandlerFor( tableStr (TableName),  tableMethodStr ( TableName , validateField))]    public   static   void  TableName_Post_validateField( XppPrePostArgs  args)   {        TableName  buffTable = args.getThis();