{"id":817,"date":"2024-10-24T15:50:32","date_gmt":"2024-10-24T07:50:32","guid":{"rendered":"https:\/\/dev-d365fo.pantheonsite.io\/?p=817"},"modified":"2024-10-24T15:50:33","modified_gmt":"2024-10-24T07:50:33","slug":"how-to-add-new-field-in-invent-on-hand-form","status":"publish","type":"post","link":"https:\/\/dev-d365fo.pantheonsite.io\/how-to-add-new-field-in-invent-on-hand-form\/","title":{"rendered":"\u5982\u4f55\u5728 D365FO \u7684\u73b0\u6709\u91cf\u67e5\u8be2\u4e2d\u589e\u52a0\u5b57\u6bb5\u548c\u6570\u636e\u6e90\uff08Add the new field or datasource in Inventory On hand form using X++ in D365FO\uff09"},"content":{"rendered":"\n
\u6211\u4eec\u9700\u8981\u4e3a\u7c7b InventDimCtrl_Frm_OnHand \u521b\u5efa\u4e00\u4e2a\u6269\u5c55\uff0c\u4ee5\u4f7f\u7528\u65b9\u6cd5 modifiedQueryBasedOnDatasourceName \u6765\u5b9e\u73b0\u8fd9\u79cdInventory On hand\u5b9a\u5236\u3002<\/p>\n\n\n\n
\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u7f51\u683c\u4e2d\u6dfb\u52a0\u5e26\u6709\u8fc7\u6ee4\u9009\u9879\u7684\u65b0\u5b57\u6bb5\u3002\uff08\u4e0d\u4f7f\u7528\u663e\u793a\u65b9\u6cd5\uff09\u3002\u6839\u636e\u9700\u6c42\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u8868\u5355\u4e2d\u6dfb\u52a0\u6765\u81ea\u73b0\u6709\u6570\u636e\u6e90\u4ee5\u53ca\u65b0\u6570\u636e\u6e90\u7684\u5b57\u6bb5\u3002<\/p>\n\n\n\n
\n[ExtensionOf(classStr(InventDimCtrl_Frm_OnHand))]\nfinal class InventDimCtrl_Frm_OnHandClass_Extension\n{\n public void modifyQueryBasedOnDatasourceName(\n Query _inventSum_DS_Query,\n str _inventSum_DS_Name,\n FormDataSource _inventDim_DS)\n {\n Query query;\n QueryBuildDataSource qbds;\n QueryBuildDataSource qbdsInventOnHandItemListView;\n QueryBuildDataSource qbdsInventTable;\n Counter loop;\n boolean qbdsExists;\n next modifyQueryBasedOnDatasourceName(_inventSum_DS_Query, _inventSum_DS_Name, _inventDim_DS);\n \u00a0\n \u00a0\u00a0\u00a0\u00a0query =\u00a0\u00a0 _inventSum_DS_Query;\n \u00a0\n \u00a0\u00a0\u00a0\u00a0qbdsInventTable = query.dataSourceTable(tableNum(InventTable));\n \u00a0\n \u00a0\u00a0\u00a0\u00a0if (qbdsInventTable)\n \u00a0\u00a0\u00a0\u00a0{\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, BinLocation));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, ItemStatus));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, PackQtyString));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, PartNumber));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, PromotionApplicable));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, PurchaseMultiple));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, ManufacturerCode));\n \u00a0\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for (loop = 1; loop <= _inventSum_DS_Query.dataSourceCount(); loop++)\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbds =\u00a0\u00a0 _inventSum_DS_Query.dataSourceNo(loop);\n \u00a0\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (qbds.table() == tableNum(InventOnHandItemListView))\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsExists = true;\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0break;\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n \u00a0\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (!qbdsExists)\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView = query.dataSourceTable(tableNum(InventTable)).addDataSource(tableNum(InventOnHandItemListView));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addLink(fieldNum(InventOnHandItemListView, ItemId), fieldNum(InventTable, ItemId));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.joinMode(JoinMode::InnerJoin);\n \u00a0\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addRange(fieldNum(InventOnHandItemListView, LanguageId)).value(queryValue(new xInfo().language()));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView = query.dataSourceTable(tableNum(InventOnHandItemListView));\n qbdsInventOnHandItemListView.addRange(fieldNum(InventOnHandItemListView, LanguageId)).value(queryValue(new xInfo().language()));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n \u00a0\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, ManufacturerName));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, VendorID));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, VendorName));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, CoverageGroup));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, ProductType));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, ItemName));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, ItemDescription));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, SearchName));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, ProductDimensionGroup));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, StorageDimensionGroup));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, TrackingDimensionGroup));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, ItemModelGroupID));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, BasePurchasePrice));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, BaseSalesPrice));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, BaseCostPrice));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, InventUnit));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, SalesUnit));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, PurchUnit));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, ItemGroupId));\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventOnHandItemListView.addGroupByField(fieldNum(InventOnHandItemListView, ProductSubType));\n \u00a0\u00a0\u00a0\u00a0}\n }\n}\n<\/pre>\n\n\n\n<\/p>\n\n\n\n
<\/p>\n","protected":false},"excerpt":{"rendered":"
\u6211\u4eec\u9700\u8981\u4e3a\u7c7b InventDimCtrl_Frm_OnHand \u521b\u5efa\u4e00\u4e2a\u6269\u5c55\uff0c\u4ee5\u4f7f\u7528\u65b9\u6cd5 modifiedQueryBasedOnDatasourceName \u6765\u5b9e\u73b0\u8fd9\u79cdInventory On hand\u5b9a\u5236\u3002 \u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u7f51\u683c\u4e2d\u6dfb\u52a0\u5e26\u6709\u8fc7\u6ee4\u9009\u9879\u7684\u65b0\u5b57\u6bb5\u3002\uff08\u4e0d\u4f7f\u7528\u663e\u793a\u65b9\u6cd5\uff09\u3002\u6839\u636e\u9700\u6c42\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u8868\u5355\u4e2d\u6dfb\u52a0\u6765\u81ea\u73b0\u6709\u6570\u636e\u6e90\u4ee5\u53ca\u65b0\u6570\u636e\u6e90\u7684\u5b57\u6bb5\u3002 [ExtensionOf(classStr(InventDimCtrl_Frm_OnHand))] final class InventDimCtrl_Frm_OnHandClass_Extension { public void modifyQueryBasedOnDatasourceName( Query _inventSum_DS_Query, str _inventSum_DS_Name, FormDataSource _inventDim_DS) { Query query; QueryBuildDataSource qbds; QueryBuildDataSource qbdsInventOnHandItemListView; QueryBuildDataSource qbdsInventTable; Counter loop; boolean qbdsExists; next modifyQueryBasedOnDatasourceName(_inventSum_DS_Query, _inventSum_DS_Name, _inventDim_DS); \u00a0 \u00a0\u00a0\u00a0\u00a0query =\u00a0\u00a0 _inventSum_DS_Query; \u00a0 \u00a0\u00a0\u00a0\u00a0qbdsInventTable = query.dataSourceTable(tableNum(InventTable)); \u00a0 \u00a0\u00a0\u00a0\u00a0if (qbdsInventTable) \u00a0\u00a0\u00a0\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, BinLocation)); \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0qbdsInventTable.addGroupByField(fieldNum(InventTable, ItemStatus)); …<\/p>\n