Changing attribute values with script

So the salesPeriodActive is my boolean attribute which I’d like to change with the help of a right click(event.button==2 didn’t work) that opens up a confirmation dialogue and upon clicking, executes the following script.

I tried a simple if(false){ grid.getActiveRecord().salesPeriodActive = true;} as well. Didn’t work.

The default value for the attribute is false (i changed it from null). This still doesn’t update or change the value yet as my console still shows:

Is there any other way/predefined function of updating the value wiithin the script?

And in general, what are the different predefined methods I can use to access data model attributes?

Hello Avinash,

If your problem was not resolved earlier, here’s one way to do it -

var record = this.getActiveRecord();
record.salesPeriodActive = !record.salesPeriodActive;

If you want the action to be controlled by a confirm box, you can add the code inside the context.confirm method like you have done above.


Thank you so much it worked!