i need to customize function custpage_applylines
# ask-stanley-ai
v
i need to customize function custpage_applylines
c
AI generated answer (using internal Slack threads):
Based on the conversations provided, it seems like you are trying to customize the function
custpage_applylines
in a way that it applies certain changes to a line item in a transaction. From the threads, it appears that you might be facing issues with getting the line count of a sublist or applying changes to a sublist. Here are some insights that might help: 1. If you are trying to get the line count of a sublist and it's returning null, make sure you are loading the record correctly and that the sublistId is correct. For example, if you are working with an invoice, the sublistId for the items would be 'item'. 2. If you are trying to apply changes to a sublist, you might need to use the
selectNewLine
method to select a new line in the sublist, then use
setCurrentSublistValue
to set the value for a field on the currently selected sublist line. After setting the values, use
commitLine
to save the changes to the current line. Here is a code sample from the threads that demonstrates this:
Copy code
javascript
var payment = record.load({
    type: record.Type.CUSTOMER_PAYMENT,
    id: srch.id,
    isDynamic: true
});
var unappliedAmount = payment.getValue('unapplied');
if (unappliedAmount > 0){
    payment.selectNewLine({
        sublistId: "apply"
    });

    payment.setCurrentSublistValue({
        sublistId: 'apply',
        fieldId: 'apply',
        value: true
    });
    payment.setCurrentSublistValue({
        sublistId: 'apply',
        fieldId: 'payment',
        value: unappliedAmount
    });
    payment.setCurrentSublistValue({
        sublistId: 'apply',
        fieldId: 'internalid',
        value: openInvoices[i].id
    });
    payment.commitLine({
        sublistId: 'item'
    });
    var saveRet = payment.save({
        enableSourcing: false,
        ignoreMandatoryFields: true
    });
    log.debug("saveRet", saveRet);
}
****** 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.795174301
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.791996539
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.786735773
Please provide your feedback on this answer.