Posts

Showing posts from May, 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;   ...

Get company address using x++ in D365FO

Get company address using x++ in D365FO CompanyInfo companyInfo = CompanyInfo::find(); info(strFmt("%1",companyInfo.postalAddress().Address));

Find on hand inventory using x++ D365 FO AX

Find on hand inventory using x++ D365 FO AX public InventQtyAvailPhysical onHandInventory(ItemId _itemId, InventDimId _inventDimId) {     InventOnhand     inventOnhand;     InventDim        inventDim = inventDim::find(_inventDimId);     InventDimParm    inventDimParm;     inventDimParm.initFromInventDim(inventDim);     inventOnhand = InventOnhand::newParameters(_itemId, inventDim, inventDimParm);     return inventOnhand.availPhysical(); }

CLEAR D365 FO AX 7 CACHE URL

CLEAR D365 FO AX 7 CACHE  Below URL can be used to directly flush the cache in D365. https://[ AOS NAME ].cloudax.dynamics.com/?mi=action:SysFlushAOD Other than this there are some methods which can be written to clear the caches private static server void clearServerGlobalObjectCaches() {     SysGlobalObjectCache::clearAllCaches(); } Below table holds the usage data SysLastValue syslastValue; userId  userId = curUserId(); ttsbegin; delete_from syslastValue where syslastValue.UserId == userId; ttscommit;

TABLE BROWSER IN D365 FO AX 7

TABLE BROWSER IN D365 FO AX 7: In non-production environment's and production environment you can use the following URL to open a web based table browser You can access it via environment url/?mi=SysTableBrowser&tableName=[tablename]&cmp=[company] Example: https://environment.cloudax.dynamics.com/?mi=SysTableBrowser&tableName=CustTable&cmp=HC Where CustTable is the table and the company is HC

Breakpoint symbols not loading in D365FO AX 7

Breakpoint symbols not loading in D365FO  AX 7 Recently i faced an issue where my breakpoints weren’t loading for objects in the AOT that were not in my solution and therefore I was not able to debug. Solution :  In order to load symbols for objects that are not been included in your solution you have to uncheck the Load Symbols check box. Dynamincs365>Options>Dynamics 365>Debugging Load symbols only for items in the solution.

CREATE MOVEMENT JOURNAL CODE IN D365 X++

CREATE MOVEMENT JOURNAL CODE IN D365 X++ static void createMovementJournalAx(Args _args) {    InventJournalTable               inventJournalTable;    InventJournalTrans               inventJournalTrans;    InventJournalNameId              inventJournalName;    InventDim                             inventDim;    JournalCheckPost                journalCheckPost;        //Below code creates journal header                inventJournal...

BP error parameter not used d365 FO AX

BP error parameter not used D365 FO AX: ,SuppressBPWarning('BPParameterNotUsed', "Parameter required"  - to end of the decorator. E.g.    [FormDataFieldEventHandler(formDataFieldStr(aForm, aDatasource, aField), FormDataFieldEventType::Validating),SuppressBPWarning('BPParameterNotUsed', "Parameter required") ] [FormDataSourceEventHandler(formDataSourceStr(EntAssetRequestTableCreate, testObjectTableView), FormDataSourceEventType::QueryExecuting),         SuppressBPWarning('BPParameterNotUsed', 'The parameter is not required in this context')]     public static void testObjectTableView_OnQueryExecuted(FormDataSource sender, FormDataSourceEventArgs e)     {      } [FormDataSourceEventHandler(formDataSourceStr(AccountingDistribution, AccountingDistribution), FormDataSourceEventType::Activated),         SuppressBPWarning('BPParameterNotUsed', 'Parameter required by the event interface')] ...

Create lookup in D365FO using X++

Create lookup in D365FO using X++ ·           Open the  form ·          Go to the  form string control  on which you want to show lookup ·          Go to the  events of the form string control  on forms ·          Right click the  OnLookup  event and click  Copy event handler method ·          Create a  new class  and  paste the event handler method in the class  you have copied in the previous step [FormControlEventHandler(formControlStr(Form, AccountNum), FormControlEventType::Lookup)] public static void AccountNum_OnLookup(FormControl sender, FormControlEventArgs e) {               //Add the lookup logic here.  } ·      ...

Calculate tax amount using x++ D365 FO AX

Calculate tax amount using x++ This code needs  four arguments .  These arguments are mentioned as follows: ·          Tax group ·          Tax item group ·          Currency code ·          Module Here is code below: Tax::calcTaxAmount(purchLine.TaxGroup, purchLine.TaxItemGroup, Systemdateget(), purchLine.CurrencyCode, purchLine.LineAmount, TaxModuleType::Purch); Pass these values to the functions, whether they come from SalesLine or PurchLine or any other table.  It will return the tax value .

CREATE AND POSTING PURCHASE ORDER THROUGH X++ DYNAMICS AX

CREATE AND POSTING PURCHASE ORDER X++ : static void PurchOrderCreate(Args _args)   { NumberSeq numberSeq; PurchTable purchTable; PurchLine purchLine; ttsBegin; numberSeq = NumberSeq::newGetNum(PurchParameters::numRefPurchId()); numberSeq.used(); purchTable.PurchId = numberSeq.num(); purchTable.initValue(); purchTable.initFromVendTable(VendTable::find('1001')); if (!purchTable.validateWrite()) { throw Exception::Error; } purchTable.insert(); purchLine.PurchId = purchTable.PurchId; purchLine.ItemId = “ItemId; purchLine.createLine(true, true, true, true, true, true); ttsCommit; info(strFmt( "Purchase order '%1' has been created", purchTable.PurchId)); } .............................................. static void PurchaseOrderPost(Args _args) { PurchFormLetter purchFormLetter; PurchTable purchTable; purchTable = PurchTable::find('purchid'); purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder); p...

Create sales order using x++

Create sales order using x++: Following is the code to create and post confirmation , packing slip and invoice sales order using x++ programming language: class CreatePostSalesOrder {     /// <summary>     /// Create sales order and posting sales order     /// </summary>     public static void main(Args _args)     {                SalesTable salesTable;         SalesLine salesLine;         InventTable inventTable;         InventDim inventDim;         CustTable custTable;         CustAccount custAccount;         NumberSeq numberSeq;         SalesId sal...