Dynamically set custom field value in client script <= how?

While the field nicely shrinks to 32, it’s value seems to be overridden. How does one do it?

frappe.ui.form.on('Subscription', {
	refresh: function(frm) {
		$("textarea[data-fieldname='custom_performance_period']").css({'height':'32'});
		$("textarea[data-fieldname='custom_performance_period']").val('asdf');
	}
});

notoriously answering my own questions, try this:

frappe.ui.form.on('Subscription', {
	refresh: function(frm) {
		$("textarea[data-fieldname='custom_performance_period']").css({'height':'32'});
    },
	onload_post_render: function(frm) {
        const d = new Date();
        var month = d.getMonth();
        var year =  d.getFullYear();
        if( month === 0 ){
          d.setFullYear(year-1);
          month = 12;
        }
        var perfPeriod = month + '/' + d.getFullYear();
        cur_frm.set_value('custom_performance_period', perfPeriod );
	}
});
1 Like