boolean canRun = false; TransDate fromDate, toDate, prevDate; TransDate currentDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()); switch (Reporting.Schedule) { case ReportingSchedule::Daily : fromDate = currentDate - 1; toDate = currentDate - 1; canRun = true; break; case ReportingSchedule::Weekly : PreferredLocale preferredLocale = (new xSession()).PreferredLocale(); prevDate = HcmDateTimeUtil::calculateDateWithOffset(PeriodUnit::Day,7,false, currentDate); fromDate = DateTimeUtil::getStartOfWeekDate(preferredLocale, prevDate); toDate = DateTimeUtil::getEndOfWeekDate(preferredLocale, prevDate); canRun = dayOfWk(currentDate) == 1; //1 for monday break; case ReportingSchedule::Monthly : prevDate = prevMth(currentDate); fromDate = DateStartMth(prevDate); toDate = endmth(prevDate); canRun = dayOfMth(currentDate) == 1; //1 for first day of the month break; }
Binarycode (Microsoft Dynamics AX 2012 and D365FO)
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
Tuesday, April 16, 2024
Calculate FromDate/ToDate based on Daily,Weelkly,Monthly in X++
Thursday, April 11, 2024
Computed column in View/DataEntity
private static server str compPurchQtyInvoiced() { //return SysComputedColumn::sum(SysComputedColumn::returnField( // tableStr(InboundOrderLinesOverview), // identifierStr(InventTransPurchLine), // fieldStr(InventTrans, Qty))); SysDictTable InventTrans = new SysDictTable(tableNum(InventTrans)); SysDictTable InventTransOriginPurchLineLoc = new SysDictTable(tableNum(InventTransOriginPurchLine)); str val; str inventtransid = SysComputedColumn::returnField(dataentityviewstr(InboundOrderLinesOverview), identifierstr(PurchLine), fieldstr(PurchLine, InventTransId)); //select SUM(QTY) from inventtrans // join InventTransOriginPurchLine on InventTransOriginPurchLine.INVENTTRANSORIGIN = inventtrans.INVENTTRANSORIGIN // where InventTransOriginPurchLine.PURCHLINEINVENTTRANSID = 'L00834739' // AND inventtrans.STATUSRECEIPT in (1,2) val = strFmt("select SUM(%1) from %2 join %3 on %3.%4 = %2.%5 where %3.%6 = %7 AND %2.%8 = %9", InventTrans.fieldName(fieldNum(InventTrans, Qty), DbBackend::Sql), InventTrans.name(DbBackend::Sql), InventTransOriginPurchLineLoc.name(DbBackend::Sql), InventTransOriginPurchLineLoc.fieldName(fieldNum(InventTransOriginPurchLine, INVENTTRANSORIGIN), DbBackend::Sql), InventTrans.fieldName(fieldNum(InventTrans, INVENTTRANSORIGIN), DbBackend::Sql), InventTransOriginPurchLineLoc.fieldName(fieldNum(InventTransOriginPurchLine, PURCHLINEINVENTTRANSID), DbBackend::Sql), inventtransid, InventTrans.fieldName(fieldNum(InventTrans, StatusReceipt), DbBackend::Sql), SysComputedColumn::returnLiteral(1)); return val; }
Subscribe to:
Posts (Atom)