Hi Community,
Good Day
How can I dynamically Hide/Unhide options under Print button based on some conditions (example based on value of some lookup field).
Like
Dear Fulgen,
In order to achieve such task you need to add custom code customization. Please see the instruction below, hope you will find it helpful. The realization should be added to the page schema.
1. Bind options' visibility on the virtual attribute. Set it to false by default:
"setFieldVisibility": { dataValueType: Terrasoft.DataValueType.BOOLEAN, type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN value: false }
2. In onEntityInitialized method call your custom method, which will be setting the attribute value to true or false based on filed value:
onEntityInitialized: function() { this.callParent(arguments); this.setOptionsVisibility(); }
3. Add custom method to check the value of the filed on the page and set visibility based on it.
In order to change dynamically, please add another attribute on the page, where based on the particular field change the method is triggered and changing the visibility:
"OnLookUpChange":{ "dependencies":[ { "columns":["UsrLookup1"], "methodName":"setOptionsVisibility" } ] }
Regards,
Anastasia
Fulgen,
There is a marketplace solution that might do what you're after: https://marketplace.bpmonline.com/app/printable-forms-filtering-bpmonli…
Anastasia Botezat,
Hi Anastasia, Thanks for your answer.
Now I can already handle event based on the value of lookup thru:
"OnLookUpChange":{ "dependencies":[ { "columns":["UsrLookup1"], "methodName":"setOptionsVisibility" } ] }
But, now how can i get the id of each printables then set it to hidden/unhidden.
try this function to hide/unhide options by Id
preparePrintFormsMenuCollection: function (printForms) {
this.callParent(arguments);
debugger;
// var stage = this.get("Stage");
printForms.eachKey(function (key, item) {
if(key !="c1af36b1-9550-46c4-8a2c-ff6450eed242".toLowerCase())
{
item.set("Visible", false);
}
}, this);
}
put it in the method property
Dear Fulgen,
Please use the code, which was provided by Mohamad. This is an overridden basic method for printable collection, which sets properties for button options. In order to check the Id of needed printables, you can right-click on the printable and inspect the item. Its Id will be indicated in the HTML id property.
In case you will have any further question, please let us know.
Regards,
Anastasia