web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Unanswered

How to add on-hand inventory quantity in Product Search View in Dynamics 365 Commerce?

(0) ShareShare
ReportReport
Posted on by 24

pastedimage1679048665091v1.png

Here is my code CustomProductSearchColumns.ts file, but on-hand quantity is not showing. Can anybody guide me how to show item on-hand quantity on Product Search

import { IProductSearchColumn } from "PosApi/Extend/Views/SearchView";
import { InventoryLookupOperationRequest, InventoryLookupOperationResponse } from "PosApi/Consume/OrgUnits";
import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns";
import { CurrencyFormatter } from "PosApi/Consume/Formatters";
import { ProxyEntities } from "PosApi/Entities";
//import { ProxyEntities } from "PosApi/ClientEntities";
import { ClientEntities} from "PosApi/Entities";

function getOnhand(context: ICustomColumnsContext, recordId: ProxyEntities.ProductSearchResult, search: ProxyEntities.OrgUnitAvailabilitySearchCriteria): Promise<number> {
return new Promise((resolve, reject) => {
let correlationId: string = context.logger.getNewCorrelationId();

let request: InventoryLookupOperationRequest<InventoryLookupOperationResponse> =
new InventoryLookupOperationRequest<InventoryLookupOperationResponse>(recordId.RecordId, correlationId, search);
console.log(`Request my debugger: ${request}`);
console.table([request]);
context.runtime.executeAsync(request)
.then((result: ClientEntities.ICancelableDataResult<InventoryLookupOperationResponse>) => {
if (!result.canceled) {
resolve(result.data.orgUnitAvailability[0].ItemAvailabilities[0].AvailableQuantity);
} else {
resolve(0);
}
})
.catch((error: any) => {
reject(error);
});
});
}


export default (context: ICustomColumnsContext): IProductSearchColumn[] => {


return [
{
title: "Item ID_CUSTOMIZED",
computeValue: (row: ProxyEntities.ProductSearchResult): string => { return row.ItemId; },
ratio: 20,
collapseOrder: 3,
minWidth: 120
}, {
title: "Name",
computeValue: (row: ProxyEntities.ProductSearchResult): string => { return row.Name; },
ratio: 40,
collapseOrder: 2,
minWidth: 150
}, {
title: "Onhand",
computeValue: (row: ProxyEntities.ProductSearchResult): string => {
let searchCriteria = new ProxyEntities.OrgUnitAvailabilitySearchCriteriaClass();
searchCriteria.OrgUnitNumber = "052";
searchCriteria.OrgUnitName = "HOUSTON"; // Set the name property
let onhand: Promise<number> = getOnhand(context, row, searchCriteria);
return onhand.toString();
},
ratio: 20,
collapseOrder: 4,
minWidth: 200
}, {
title: "Price",
computeValue: (row: ProxyEntities.ProductSearchResult): string => { return CurrencyFormatter.toCurrency(row.Price); },
ratio: 20,
collapseOrder: 1,
minWidth: 100,
isRightAligned: true
}
];
};

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 185 Super User 2026 Season 1

#2
Mallesh Deshapaga Profile Picture

Mallesh Deshapaga 105

#3
Laurens vd Tang Profile Picture

Laurens vd Tang 98 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans