Posts

Showing posts from January, 2025

Remove Financial Dimension in D365fo x++

Remove Financial Dimension in D365fo x++ public static DimensionDefault removeDimension(Common _common, str _fieldname = 'DefaultDimension', boolean _update = true, str Sector = 'Sector') { FieldId _FieldId = fieldName2Id(_common.TableId, _fieldname); DimensionDefault _defaultDimension = _common.(_FieldId); if(_defaultDimension) { DimensionAttributeValueSetStorage dimStorage = new DimensionAttributeValueSetStorage(); dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimension); DimensionValue displayValue = dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName(Sector).RecId); if(displayValue) { DimensionAttributeValue dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::findByName(Sector), displayValue, false, false); dimStorage.removeDimensionAttributeValu...

SalesLine Reservation in D365fo x++

SalesLine Reservation in D365fo x++ SQL: /// <summary> /// reserve sales line /// </summary> /// <param name = "_salesline">SalesLine</param> public static void reserveSalesLine(SalesLine _salesline) { InventBatch inventBatch; InventSum inventSum; SalesLine salesLine; InventDim inventDim; InventTable inventTable; int daysLeftforExpiry = 0; int shelflife; int rule = 0; int acceptedPR = 0; Qty qtyReserve = 0; Qty saleLineQty = 0; DSAPickingRulePerId pickingrule; boolean qtyReservedCheck = false; salesLine = _salesline; pickingrule = _salesline.salesTable().DSAPickingRule; if(pickingrule == '') { warning("Picking rule is not available on sales order for reservation."); } else { ...

getAvailableForReservationReserve in D365fo x++

   getAvailableForReservationReserve in D365fo x++ SQL: public static Qty getAvailableForReservation(SalesLine _salesline) { InventSum inventSum; Qty availableForReservation = 0; while select inventSum where inventSum.ItemId == _salesline.ItemId { availableForReservation = availableForReservation + inventSum.availReservation(); } return availableForReservation; }

update Reserve in D365fo x++

 update Reserve in D365fo x++ SQL: /// <summary> /// reserve sales line /// </summary> /// <param name = "_salesLine">SalesLine</param> /// <param name = "_batchId">InventBatchId</param> /// <param name = "_qtyReserve">Qry</param> public static void updateReserve(SalesLine _salesLine, InventBatchId _batchId, Qty _qtyReserve) { InventDimParm inventDimParm; InventTrans inventTrans; InventDim inventDim; #define.ZERO(0) try { inventTrans = InventTrans::findTransId(_salesLine.InventTransId); inventdim.inventDimId = _salesLine.InventDimId; inventdim.inventBatchId = _batchId; inventDim = InventDim::findOrCreate(inventDim); inventDimParm.initFromInventDim(inventDim); InventUpd_Reservation::updateReserveFromForm(_salesLine ...

Get Physical reserved of item in D365fo x++

  Get Physical reserved of item in D365fo x++ SQL: public static Qty getPhysicalReserved(ItemId _itemId, InventDimId _inventDimId) { InventOnhand inventonhand ; InventDim inventdim; InventDimParm inventdimparm; Qty qty; inventdim.inventDimId = _inventDimId; inventdim.InventSiteId = InventDim::find(_inventDimId).InventSiteId; inventdim.inventlocationid = InventDim::find(_inventDimId).InventLocationId; inventdimparm.initFromInventDim(inventdim); inventonhand = InventOnhand::newParameters(_itemId, inventdim, inventdimparm); qty = inventonhand.reservPhysical(); return qty; }

Get Tracking dimension of item in D365fo x++

Get Tracking dimension of item in D365fo x++ SQL: /// <summary> /// check if batch active for item /// </summary> /// <param name = "_itemId">ItemId</param> /// <returns>boolean</returns> public static boolean isBatchActive(ItemId _itemId) { FieldId observedDimension = fieldNum(InventDim, InventBatchId); str label = fieldPName(InventDim, InventBatchId); NoYes isActive; isActive = ecoResTrackingDimensionGroupFldSetup::findByDimensionGroupFieldId (InventTable::find(_itemId).trackingDimensionGroup(), observedDimension).IsActive; if(isActive) { return true; } else { return false; } }

SQL Query to FD's Description

    SQL Query to FD's Description  SQL: select DimensionFinancialTag.VALUE, DimensionFinancialTag.DESCRIPTION from DEFAULTDIMENSIONVIEW join DimensionAttributeDirCategory on DimensionAttributeDirCategory.DimensionAttribute = DEFAULTDIMENSIONVIEW.DIMENSIONATTRIBUTEID join DimensionFinancialTag on DimensionFinancialTag.FinancialTagCategory = DimensionAttributeDirCategory.DirCategory and DimensionFinancialTag.VALUE = DEFAULTDIMENSIONVIEW.DISPLAYVALUE where DEFAULTDIMENSIONVIEW.NAME = 'Division' And DEFAULTDIMENSIONVIEW.DEFAULTDIMENSION = 5637826338

SQL Queries for workflow and its history

  SQL Queries for workflow and its history SQL: SELECT * FROM WORKFLOWTRACKINGSTATUSTABLE T1 JOIN WORKFLOWWORKITEMTABLE T2 on T1.CORRELATIONID = T2.CORRELATIONID where t1.INSTANCENUMBER = 017745 SELECT * FROM WORKFLOWTRACKINGSTATUSTABLE T1 JOIN WORKFLOWTRACKINGTABLE T2 on T1.RECID = T2.WORKFLOWTRACKINGSTATUSTABLE LEFT OUTER JOIN WORKFLOWTRACKINGCOMMENTTABLE T3 ON T2.RECID = T3.WORKFLOWTRACKINGTABLE where t1.INSTANCENUMBER = 017745