How change the value of child table filed?

I want to change value of field “Rate” In table “items” in Purchase Invoice from JS code

There is a relevant discussion Set Value Into Child table field which could help. What is the event on which you want to change this value? When the Purchase Order loads or change of certain field?