In client script, I'm setting rate and amount in P...
# suitescript
b
In client script, I'm setting rate and amount in PostSourcing entry point but they are not changing. I changed Price Level to Custom and it works.
Copy code
curRec.setCurrentSublistValue({
                            sublistId: "item",
                            fieldId: "price",
                            value: -1
                        });
                        curRec.setCurrentSublistValue({
                            sublistId: "item",
                            fieldId: "rate",
                            value: 5
                        });
                        curRec.setCurrentSublistValue({
                            sublistId: "item",
                            fieldId: "amount",
                            value: 10
                        });
But the rate and amount didn't change. Is there any something I did wrong?
b
setCurrentSublistValue is actually asynchronous, the price level, rate and amount arent actually set when the code runs
its set later, which is a problem when the order starts mattering
setting the price level to to custom also unsets the rate and amount
which means you now have a race condition where the rate and amount can have different values depending on if the price level unsets the amount and rate before or after your code sets the rate and amount
you can also cause a similar race condition by running the code on the post sourcing of the wrong field, for example tax code
forceSyncSourcing usually helps