Forum Discussion

R_'s avatar
R_
Creator I
9 years ago

Hide and show relationship tab depend on classification of Item

hi, i want hide relationship tab depend on classification of item for classification - Equipment - hide 1)AML, 2) CAD File, 3)Documents for classification -Tool- hide 1)AML, 2)Attachments, 3)Documents for other classification -hide 1)Maintenance Plans, 2)MSA, 3)Attachments i able to hide tab but not able to show it again if i open item form it hide 1)Maintenance Plans, 2)MSA, 3)Attachments but when i select classification as Equipment it not show 1) Maintenance Plan 2)Attachement tab (which is hide when item open) i write code to hide and show tab but it not able to show all tab it only show first line of show tab code //hide relationship depend on classification of item
function tryRun() {
    if (!parent.relationships) {
        setTimeout(tryRun, 100);
        return;
    }

    if (parent.relationships.document.readyState != "complete" || !parent.relationships.currTabID) {
        setTimeout(tryRun, 100);
    }
    else {
        var tabbar = parent.relationships.relTabbar;
        if (document.thisItem.getProperty("classification", "") == "Equipment") {
            //
            //for attachement
            tabbar.SetTabVisible('810DEFB14CD44050B599296ADCD99124', 1);
            //for maintainence plan
            // var tabbar2 = parent.relationships.relTabbar;
            tabbar.SetTabVisible('1B836691ECF84263B885EE4CA8427525', 1);
            //for MSA
            tabbar.SetTabVisible('94961F7052D440EB95F0769CD098486A', true);

            parent.relationships.relTabbar.removeTabByLabel("AML");
            parent.relationships.relTabbar.removeTabByLabel("CAD File");
            parent.relationships.relTabbar.removeTabByLabel("Documents");
            parent.relationships.relTabbar.removeTabByLabel("BOM/Item");
            parent.relationships.relTabbar.removeTabByLabel("MSA");

        }
        else if (document.thisItem.getProperty("classification", "") == "Tool") {
            parent.relationships.relTabbar.removeTabByLabel("AML");
            parent.relationships.relTabbar.removeTabByLabel("Attachments");
            parent.relationships.relTabbar.removeTabByLabel("Documents");
            parent.relationships.relTabbar.removeTabByLabel("Maintainence Plans");
            parent.relationships.relTabbar.removeTabByLabel("Tool");
        }
        else {
            //tabbar = parent.relationships.relTabbar;
            tabID = tabbar.GetTabId("Maintainence Plans");
            tabID1 = tabbar.GetTabId("Attachments");
            tabID2 = tabbar.GetTabId("MSA");
            if (tabID) {
                tabbar.SetTabVisible(tabID, false);
            }
            if (tabID1) {
                tabbar.SetTabVisible(tabID1, false);
            }
            if (tabID2) {
                tabbar.SetTabVisible(tabID2, false);
            }

            // parent.relationships.relTabbar.removeTabByLabel("Maintainence Plans");
        }
    }

}
setTimeout(tryRun, 100);

  in equipment condition it only able to reshow attachment tab not maintenance plan tab

1 Reply

  • Why in one case you use "removeTabByLabel" and in the other case you use "SetTabVisible" I'd suggest you only use "SetTabVisible" and change the second parameter to set it visible or hidden.