how to set printable property at runtime

I have a report with several fields, one of them is an optional field with label.

The printable property for the label is currently set to Yes, but I would like to set it to No; then at runtime change it to Yes if the notes field has data.

Any suggestions on how to change the printable property at runtime when a field has data?

You can change it using the solutionModel:

var _jsForm = solutionModel.getForm("yourform");
_jsLabel = _jsForm.getLabel("yourlabel");
_jsLabel.printable = true;
forms.yourform.controller.recreateUI();

But I think it would be a lot easier to use a calculation as the dataprovider of the label:

if (notes) {
	return "yourtext/yourimage";
}
return "";

Then it is just “shown” and “hidden” automatically.

This looks like it should work, however I need the label to print only if a different field (note) has data - if the field has no data then the label should not print

var _jsForm = solutionModel.getForm("printForm");
var _jsLabel = _jsForm.getLabel("label");
var _jsNote = _jsForm.getComponent("note");

if (_jsNote != null){
_jsLabel.printable = true;
}

but this is not working.

You forgot to recreate your form after changing it through the Solution Model. You should add:

_jsForm.controller.recreateUI();