Posts

Showing posts from August, 2025

Run sql statement query in D365fo x++

Run sql statement query in D365fo x++ private int getMTDUniqueSKUsSold(TransDate _fromDate, TransDate _toDate, str _empId, InventSiteId _inventSite, str _division) { int uniqueCount; str fromDateStr = date2Str(_fromDate, 321, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4); str toDateStr = date2Str(_toDate, 321, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4); str sql = strFmt(@" SELECT COUNT(DISTINCT CIT.ItemId) FROM CustInvoiceTrans CIT JOIN CustInvoiceJour CIJ ON CIT.InvoiceId = CIJ.InvoiceId JOIN SalesTable ST ON ST.SalesId = CIJ.SalesId JOIN DefaultDimensionView DDV ON DDV.DefaultDimension = ST.DefaultDimension JOIN HcmWorker HW ON HW.RecId = ST.WorkerSalesResponsible WHERE CIJ.InvoiceDate >= '%1' AND CIJ.InvoiceDate <= '%2' AND ST.InventSiteId = '%3' AND DDV.Name = '...

Customer aging in D365fo x++

Customer aging in D365fo x++ //call container con0To5 = this.calculateAging(monthToDate - 5, monthToDate, hcmworker.PersonnelNumber, salestable.InventSiteId, DefaultDimensionView.DisplayValue); container con6To15 = this.calculateAging(monthToDate - 15, monthToDate - 6, hcmworker.PersonnelNumber, salestable.InventSiteId, DefaultDimensionView.DisplayValue); container con15To31 = this.calculateAging(monthToDate - 30, monthToDate - 16, hcmworker.PersonnelNumber, salestable.InventSiteId, DefaultDimensionView.DisplayValue); container con31To60 = this.calculateAging(monthToDate - 60, monthToDate - 31, hcmworker.PersonnelNumber, salestable.InventSiteId, DefaultDimensionView.DisplayValue); container con61To90 = this.calculateAging(monthToDate - 90, monthToDate - 61, hcmworker.PersonnelNumber, salestable.InventSiteId, DefaultDimensionView.DisplayValue); container con95ToAbov = this.calculateAging(dateMax() ,monthToDate - 90, hcmworker.PersonnelNumber, salestable.Inve...

Method util in D365fo x++

Method util in D365fo x++ internal final class DSSMethodCalculation { DSSMethodId methodId; DSSMethod method; DSSUserId userId; DSSUsers dssUser; DSSTransDate transDate; DSSRefRecId refRecId; DSSRefTableId refTableId; anytype result; DSSArgs args; Args defaultArgs; Common common; public static DSSMethodCalculation construct() { return new DSSMethodCalculation(); } private void new() { } public void parmArgs(DSSArgs _args) { args = _args; } public void parmDefaultArgs(Args _args) { defaultArgs = _args; } public void parmMethod(DSSMethodId _methodId) { methodId = _methodId; } public void parmUserId(DSSUserId _userId) { userId = _userId; } public void parmTransDate(DSSTransDate _transDate) { transDate = _transDate; } public void parmRefRecId(DSSRefRecId _refRecId) { refRecId = _refRecId; ...

Payment creation util in D365fo x++

Payment creation util in D365fo x++ Public class DSPMPaymentCreationUtil { public static void main(Args _args) { DSPMRentReservation DSPMRentReservation = _args.record(); DSPMRentReservationLine DSPMRentReservationLine; CustTable CustTable = CustTable::find(DSPMRentReservation.CustAccount); if(!CustTable) {throw error("Customer not found!");} select count(Property) from DSPMRentReservationLine group by DSPMRentReservationLine.Property where DSPMRentReservationLine.ReservationId == DSPMRentReservation.ReservationId && DSPMRentReservationLine.PaymentStatus == DSPMPaymentStatus::None; if(DSPMRentReservationLine.Property) { DSPMRentReservationLine.clear(); ledgerJournalTable ledgerJournalTable = DSPMPaymentCreationUtil::createLedgerJournal(DSPMRentReservation.ReservationId); if(ledgerJournalTable) { ...

Merge label on report in D365fo x++

Merge label on report in D365fo x++ =IIF(RunningValue(Fields!PrintLabel.Value, CountDistinct, "Tablix1") = 1, "Earnings","")  

Title field on Datasource in D365fo x++

Title field on Datasource in D365fo x++ public TitleFields titleFields(Common _record) { TitleFields ret; ret = next titleFields(_record); SalesTable _salesTable = _record as SalesTable; if(_salesTable.SalesType == SalesType::ReturnItem && _salesTable.ReturnItemNum && curExt() == '5010') { return strFmt('%1 : %2', _salesTable.ReturnItemNum, _salesTable.SalesName); } return ret; }