Hi All,

 

Is there a way to do a validation on printable menu items ?

 

Example : To enable the printable only when the stage is approved ( Attached Screenshot )

 

Like 0

Like

4 comments
Best reply

Sethu Raghav,

Yes it does. The article outlines adding the code to filter the list of printables to both the section (for section records and also when opened in combined mode) and the page as well for when a record is opened in edit mode.

Ryan

I have an article showing how to show/hide printables based on a value of the current record here: 

https://customerfx.com/article/showing-or-hiding-printables-based-on-a-…

You can use this method to show/hide printables only when the stage reaches the approved stage.

Ryan

Ryan Farley,

Thanks Ryan, the code also applies for section page printable too ? 

Sethu Raghav,

Yes it does. The article outlines adding the code to filter the list of printables to both the section (for section records and also when opened in combined mode) and the page as well for when a record is opened in edit mode.

Ryan

Hi Ryan,

 

I tried the code that you suggested for both section and edit page and it is working fine for the edit page. However, for the section page, the filteration is not working and it is showing the complete list of printables available for the section.

 

Please find the code below for section page filteration:

Filteration is to be done for the lookup : "UsrDocumentRepositorySubtype"

 

methods: {
// since we'll be determining if the printable is viewable
// based on the Type column, we need to make sure that column
// is available in the section list query
initQueryColumns: function(esq) {
    this.callParent(arguments);
 
    if (!esq.columns.contains("UsrDocumentRepositorySubtype")) {
        esq.addColumn("UsrDocumentRepositorySubtype");
    }
},
 
// now we need to wire up the Visible property of each menu item
// to our own function where we'll check the type column and return
// whether or not the printable should be shown
initCardPrintForms: function() {
    this.callParent(arguments);
 
    var printMenuItems = this.get(this.moduleCardPrintFormsCollectionName);
    if (Ext.isEmpty(printMenuItems)) return;
 
    printMenuItems.each(function(item) {
        item.set("Visible", {bindTo: "getPrintMenuItemVisible"});
    }, this);
},
 
// this is the function will determine if a printable is visible
// it is called for each printable and will return true/false to show or hide
getPrintMenuItemVisible: function(reportId) {
    if (Ext.isEmpty(this.get("ActiveRow"))) return true;
 
    var type = this.get("GridData").get(this.get("ActiveRow")).get("UsrDocumentRepositorySubtype") || { displayName: "" },
        printMenuItems = this.get(this.moduleCardPrintFormsCollectionName),
        item = printMenuItems.find(reportId);
 
    if (Ext.isEmpty(item)) return;
 
    switch (item.get("Caption")) {
         case "Mining and Quarrying Questionnaire":
            return type.displayValue === "Mining and Quarrying Questionnaire";
		case "Alcohol Questionnaire":
            return type.displayValue === "Alcohol Questionnaire";
        default:
            return true;
    }
}
		}

 

Kindly help.

 

Thanks and best regards,

Sarika

Show all comments