how to set the currency field of the itemvendorpri...
# ask-stanley-ai
s
how to set the currency field of the itemvendorpricelines
c
AI generated answer (using internal Slack threads):
To set the currency field of the itemvendorpricelines when multi-currency is enabled, you need to work with the 'itemvendor' sublist and the 'itemvendorprice' subrecord. Here is a sample code snippet that demonstrates how to set the currency and purchase price for a vendor:
Copy code
javascript
var itemRecord = record.load({
    type: record.Type.INVENTORY_ITEM, 
    id: 'your_item_id',
    isDynamic: true
});

var vendorSublistLine = itemRecord.findSublistLineWithValue({
    sublistId: 'itemvendor',
    fieldId: 'vendor',
    value: 'your_vendor_id'
});

if (vendorSublistLine !== -1) {
    itemRecord.selectLine({
        sublistId: 'itemvendor',
        line: vendorSublistLine
    });

    var vendorPriceSubrecord = itemRecord.getCurrentSublistSubrecord({
        sublistId: 'itemvendor',
        fieldId: 'itemvendorprice'
    });

    vendorPriceSubrecord.selectNewLine({
        sublistId: 'itemvendorpricelines'
    });

    vendorPriceSubrecord.setCurrentSublistValue({
        sublistId: 'itemvendorpricelines',
        fieldId: 'currency',
        value: 'your_currency_id'
    });

    vendorPriceSubrecord.setCurrentSublistValue({
        sublistId: 'itemvendorpricelines',
        fieldId: 'purchaseprice',
        value: 'your_purchase_price'
    });

    vendorPriceSubrecord.commitLine({
        sublistId: 'itemvendorpricelines'
    });

    itemRecord.commitLine({
        sublistId: 'itemvendor'
    });
}

itemRecord.save();
Please replace 'your_item_id', 'your_vendor_id', 'your_currency_id', and 'your_purchase_price' with your actual values. ****** 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.843566895
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822509885
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.808288693
Please provide your feedback on this answer.