how do I get discount items on a sales order to st...
# ask-stanley-ai
m
how do I get discount items on a sales order to stop converting to a percentage when transforming to a return authorization without having to update a setting.
c
AI generated answer (using internal Slack threads):
To stop discount items on a sales order from converting to a percentage when transforming to a return authorization without having to update a setting, you would need to use SuiteScript to control the transformation process. Unfortunately, without modifying the setting under Setup > Accounting > Accounting Preferences > Order Management > Convert Absolute Discounts to Percentage, the system will automatically convert absolute discounts to percentages. However, you can create a User Event script that triggers before the record is loaded. In this script, you can check if the record type is a return authorization and if it is, you can iterate over the line items and manually set the discount rate to the absolute value from the original sales order. Here's a rough example of how you might do this:
Copy code
javascript
function beforeLoad(type, form, request){
    if (type == 'view' || type == 'edit'){
        var record = nlapiGetNewRecord();
        if (record.getRecordType() == 'returnauthorization'){
            var lineCount = record.getLineItemCount('item');
            for (var i = 1; i <= lineCount; i++){
                var discountRate = record.getLineItemValue('item', 'discountrate', i);
                record.setLineItemValue('item', 'discountrate', i, discountRate);
            }
        }
    }
}
Please note that this is a simplified example and may not cover all edge cases. You would need to adjust this to fit your specific needs. ****** 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.828006506
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.827171147
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826585591
Please provide your feedback on this answer.