On payment record, how can a custom field be added...
# ask-stanley-ai
n
On payment record, how can a custom field be added to show in the summary box that captures original amount applied without discount?
c
AI generated answer (using internal Slack threads):
To add a custom field on a payment record that captures the original amount applied without discount and shows in the summary box, you can follow these steps: 1. Navigate to Customization > Lists, Records, & Fields > Transaction Body Fields > New. 2. In the Label field, enter a name for the custom field (e.g., "Original Amount Applied"). 3. Set the Type to Currency. 4. In the Applies To section, select Payment. 5. In the Display section, set the Subtab to Main. 6. In the Display section, set the Display Type to Normal. 7. In the Validation & Defaulting section, you can set a Default Value if needed. 8. Save the custom field. Now, to populate this field with the original amount applied without discount, you would need to use a User Event script or a Scheduled script. The script would need to calculate the original amount applied without discount and then set this value in the custom field you created. Here is a sample script:
Copy code
javascript
function beforeSubmit(type){
    if(type == 'create' || type == 'edit'){
        var record = nlapiGetNewRecord();
        var total = 0;
        var lineCount = record.getLineItemCount('apply');
        for(var i = 1; i <= lineCount; i++){
            var apply = record.getLineItemValue('apply', 'apply', i);
            if(apply == 'T'){
                var amount = parseFloat(record.getLineItemValue('apply', 'amount', i));
                total += amount;
            }
        }
        record.setFieldValue('custbody_original_amount_applied', total);
    }
}
This script gets the line items from the 'apply' sublist of the payment record, checks if they are applied, and if so, adds their amounts to a total. This total is then set as the value of the custom field. ****** 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.83415395
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830097675
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829046965
Please provide your feedback on this answer.