how to include item location average cost on an it...
# ask-stanley-ai
c
how to include item location average cost on an item search
c
AI generated answer (using internal Slack threads):
To include item location average cost in an item search, you can use the 'locationaveragecost' field. This field is not visible in the SuiteScript browsers but it is available for searches. Here is a sample code snippet for a SuiteScript search that includes the 'locationaveragecost' field:
Copy code
javascript
var filters = [];
var columns = [];

filters.push(search.createFilter({
    name: 'internalid',
    operator: search.Operator.ANYOF,
    values: [itemId]
}));

columns.push(search.createColumn({
    name: 'locationaveragecost',
    join: 'inventoryLocation'
}));

var itemSearch = search.create({
    type: search.Type.ITEM,
    filters: filters,
    columns: columns
});

itemSearch.run().each(function(result) {
    var locationAverageCost = result.getValue({
        name: 'locationaveragecost',
        join: 'inventoryLocation'
    });
    log.debug('Location Average Cost', locationAverageCost);
    return true;
});
This script creates a search on the Item record, filters for a specific item ID, and retrieves the 'locationaveragecost' field. The 'locationaveragecost' field is joined with the 'inventoryLocation' field to get the average cost for each location. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.846458852
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830321491
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.827364624
Please provide your feedback on this answer.