Hi all! I'm trying to <add an item line> to the ca...
# suitecommerce
e
Hi all! I'm trying to add an item line to the cart programmatically, but I need to set a custom price level. I'm setting the "rate" key on the line, but I'm having no success, the items still gets added with its base price. Any tips?
e
@Esteban Damazio is this a dynamic value that depends on specific conditions? I ask due that you can set specific custom price level of an item from the customer record and it will only apply to this specific customer. However if this custom price only applies under specific conditions for that customer, then you need to try the scriptable cart. The extensibility API will always use the rate set on the current session of your customer.
e
It is a dynamic value indeed.
Ok I will switch my implementation to the scriptable cart. I've never used the scriptable cart. I did see through some logs that the context parameter of the validateLine function is a "currentRecord" element. Will using
record.setSublistvalue ("pricelevel")
(<- that's pseudocode) work similarly to regular backend suitescript?
@eminero btw thank you for your answer
e
I do not have it at top of my mind right now, but I would try this first in the UI of NetSuite and then check the field ids, but If I'm not wrong you need to play with rate and another field which in the UI would say something like 'custom rate/price'. Start here: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/article_0151255693.html#subsect_69145908833
❤️ 1
e
Thank you very much! I will report back for future reference once I solve this.
🤝 1
Copy code
/**
 * @NApiVersion 2.0
 * @NScriptType ClientScript
 */

export function validateLine(context: EntryPoints.Client.validateLineContext){
    try {
        const sublistId = context.sublistId;
        const rate: number = getRate(context);
        context.currentRecord.setCurrentSublistValue({fieldId: "pricelevel", value: "-1", sublistId: sublistId});
        context.currentRecord.setCurrentSublistValue({fieldId: "rate", value: rate, sublistId: sublistId});
        return true;
    } catch (e) {
        alert("Error" + " " + e.message + ": " + e.stack + "");
        return false;

    }
}
This worked for me! Thank you @eminero
🙌 1
e
Awesome! Glad you made it work.