write an example of a transaction cash sale using ...
# ask-stanley-ai
m
write an example of a transaction cash sale using suitescript 2.x setting up values, lines, paymentmethod and account
c
AI generated answer (using internal Slack threads):
Based on the conversations, here is an example of how you can create a cash sale transaction using SuiteScript 2.x:
Copy code
javascript
var record = require('N/record');

var cashSaleRecord = record.create({
    type: record.Type.CASH_SALE,
    isDynamic: true,
});

cashSaleRecord.setValue({
    fieldId: 'entity',
    value: '123' // replace with actual customer internal id
});

cashSaleRecord.setValue({
    fieldId: 'paymentmethod',
    value: '4' // replace with actual payment method internal id
});

cashSaleRecord.setValue({
    fieldId: 'account',
    value: '200' // replace with actual account internal id
});

var lineNum = cashSaleRecord.selectNewLine({
    sublistId: 'item'
});

cashSaleRecord.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'item',
    value: '567' // replace with actual item internal id
});

cashSaleRecord.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'quantity',
    value: 1
});

cashSaleRecord.commitLine({
    sublistId: 'item'
});

var cashSaleId = cashSaleRecord.save({
    enableSourcing: true,
    ignoreMandatoryFields: true
});
This script creates a new cash sale record, sets the customer, payment method, and account, adds a line item, and then saves the record. Please replace the placeholder values with actual internal ids. ****** 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.836048126
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823783875
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822946429
Please provide your feedback on this answer.