Posts

Showing posts from January, 2025

can add date range like this in D365 FO x++

  qbds.addRange(fieldNum(RetailInternalOrgProductAssortedDisplay, validFrom)).value('..' + queryValue(utcNow));             qbds.addRange(fieldNum(RetailInternalOrgProductAssortedDisplay, validTo)).value(queryValue(utcNow) + '..');

sales invoice by sales line wise through code in x++

  private custInvoiceJour salesOrderInvoiceByLine(SalesLine    _salesline)  {      salesFormLetter         salesFormLetter;      salesFormletterParmData salesFormLetterParmData;      salesParmUpdate         salesParmUpdate;      salesParmTable          salesParmTable;      salesParmLine           salesParmLine;      salesTable              salesTable;      custInvoiceJour custInvoiceJourLocal;      salesTable  = salesTable::find(_salesline.SalesId);               ttsbegin;      salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::Invoice, VersioningUpdateType::Initial);      salesFormLetterParmData.parmOnlyCreateParm...

voucher to Purchase order

   //inserting Records         insert_recordset    DAK_VoucherTransactionTmpLoc(SubledgerVoucherDataAreaId, SubledgerVoucher, AccountingDate, SubledgerJournalEntry,PurchId,PurchStatus,DocumentState)             select SubledgerVoucherDataAreaId, SubledgerVoucher, AccountingDate, SubledgerJournalEntry from GeneralJournalEntryLoc             join subledgerVoucherGeneralJournalEntryLoc             where subledgerVoucherGeneralJournalEntryLoc.GeneralJournalEntry   ==  GeneralJournalEntryLoc.RecId             join vendInvoiceJour                 where vendInvoiceJour.CostLedgerVoucher == subledgerVoucherGeneralJournalEntryLoc.Voucher                    && vendInvoiceJour.InvoiceDate == subledgerVoucherGeneralJournalEntryLoc...

Sample method how to write Computed column method in x++

public static server str getSalesLineRecid()     {         str SalesLineRecidLoc;         str RecidLoc = SysComputedColumn::returnField(tablestr(SalesOrderLineV2Entity), identifierstr(SalesLine), fieldstr(SalesLine, RecId));         str DataAreaIdLoc = SysComputedColumn::returnField(tablestr(SalesOrderLineV2Entity), identifierstr(SalesLine), fieldstr(SalesLine, DataAreaId));         SalesLineRecidLoc = strFmt(@"select top 1 SalesLine.RecId from SalesLine where SalesLine.RecId = %1 and SalesLine.DataAreaId = %2", RecidLoc,DataAreaIdLoc);         return   SalesLineRecidLoc;     }

To bypass table level field validation on data entity in x++

   /// <summary>     ///     /// </summary>     /// <param name = "_entityCtx"></param>     public void persistEntity(DataEntityRuntimeContext _entityCtx)     {         this.skipDataSourceValidateField(fieldNum(TableName, RefTableId), true);         this.skipDataSourceValidateField(fieldNum(TableName, JoinTableId), true);         super(_entityCtx);     } Regards Muhammad Farraz Email:      farazjaved01@gmail.com

Adding Date Range in AOT Query

Image
 

activate workflow and submitted through code in x++

   //Triggered ERE Visa Request workflow after business trip workflow completion         if(employeeBusinessTrip.WorkflowStatus == DSPWorkflowStatus::Completed)         {             select visaRequest                     where visaRequest.TripId == employeeBusinessTrip.TripId                     && visaRequest.EmployeeId == employeeBusinessTrip.EmployeeId;             if(visaRequest)             {                 //Check whether we have a Active workflow on the table.                 workflowVersionTable = Workflow::findWorkflowConfigToActivateForType(workFlowTypeStr(DSPEREVisaRequestWorkflowType),                   ...

How To Get Dynamics 365 F&O URL through code - X++

   var app = Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory::GetApplicationEnvironment(); Str envURL= app.Infrastructure.HostUrl; Regards: farazjaved01@gmial.com

dimension control Enable Disable

 Public class DSADimensionEntryControlUtil {     //Enable Disable Sector Dimension     public static void disableDimension(custtable custtable, DimensionEntryControl dimControl , str Sector = 'Sector')     {                  DimensionEnumeration            dimensionSetId               = DimensionCache::getDimensionAttributeSetForLedger();         DimensionAttributeSetStorage    dimensionAttributeSetStorage = new DimensionAttributeSetStorage();         DimensionAttribute              dimensionAttribute;         DimensionAttributeSetItem       dimAttrSetItem;         if(custtable.DSACustomerSectorType == DSACustomerSectorType::MultiSector)         {         ...