ransok - Monday, June 9, 2014 3:21 AM:
Hi,
I am trying to disable/enable an Item's tab based on its classification. I created OnChange event for classification field on item's form and added the following code:
top.Tab = function ()
{
if (!parent.relationships)
{
setTimeout("top.Tab();", 100);
return;
}
var rel_tabs = "Cleaning Activities"; // Relationship Name
var tabsIds = top.aras.getRelationshipTypeId(rel_tabs);
if (parent.relationships.document.readyState != "complete" || !parent.relationships.currTabID)
{setTimeout("top.Tab();", 100); }
else
{
var recp_tabs = tabsIds;
var recp_type = parent.item.selectSingleNode("classification");
if (recp_type)
{
recp_type = recp_type.text;
alert(recp_type);
if(recp_type.indexOf("Cleaning") > -1)
{
parent.relationships.document.relTabbar.setTabEnabled(tabsIds, 1);
}
else
{
parent.relationships.document.relTabbar.setTabEnabled(tabsIds, 0);
}
}
}
};
setTimeout("top.Tab()", 200);
I found this code in a Form Event of ItemType's form.
This is not working, I am not facing any errors but it is not disabling the tab if I select other classification type. I am using Innovator 10.0
Any issues with my code? Please help me.
DavidSpackman - Tuesday, June 10, 2014 10:52 PM:
Hi Ransok,
Here is some code we use to do this
- Create an onLoad js function to hold the "API" (lowest number in the sort order)
- Create a 2nd onLoad js function to run the TabOnLoad function when the foam loads (define if the tab should be shown or not) example
- top.TabOnLoad();
- Create other js functions to use onChange
See the PE_ChooseCMOptions form for an example
onLoadAPI
OnChange Example for a drop down list
pankaj - Thursday, June 12, 2014 1:28 AM:
Hi Ransok,
You have to write this code in OnformPopulated event.
var recp_type = parent.item.selectSingleNode("classification");
if (recp_type)
{
top.hidePartTabsByBusinessLogic = function()
{
var tabbar = parent.relationships.relTabbar;
var cleaning_act = tabbar.GetTabId("Cleaning Activities");
if(cleaning_act)
{
tabbar.setTabVisible(cleaning_act,false);
}
};
setTimeout("top.hidePartTabsByBusinessLogic();", 30);
return;
}
Regards,
Pankaj B
ransok - Thursday, June 12, 2014 5:21 AM:
Thank you so much DavidSpackman,
Hiding the tabs is happening as required but displaying back the hidden tabs is not working properly when I select any other classification.
I mean if I select classification as 'Cleaning' then two tabs will be hidden. Now if I change the classification then I should see the two hidden tabs displaying back but I see only one hidden Tab displaying some times and nothing some times.
That's why I was trying for Disabling and Enabling the Tabs.
pankaj - Thursday, June 12, 2014 8:57 AM:
Hi Ransok,
Could you try my code. which i suggested.
ransok - Friday, June 13, 2014 4:22 AM:
Thank you Pankaj,
I tried you code. I am able to hide the tab using your code but I am not able to show the hidden tab back.
I added this for showing hidden Tab:
if (recp_type)
{
if(recp_type!="Cleaning")
{
top.showPartTabsByBusinessLogic = function()
{
var tabbar = parent.relationships.relTabbar;
var cleaning_act = tabbar.GetTabId("Cleaning Activities"); //--- here it is getting a null value
if(cleaning_act)
{
tabbar.setTabVisible(cleaning_act,true);
}
};
setTimeout("top.showPartTabsByBusinessLogic();", 30);
return;
}
}
pankaj - Friday, June 13, 2014 8:29 AM:
Hi Ransok,
1) Is "Cleaning Activities" a Tab label name . .?.
2) The "classification" that you are selecting belongs to existing form or other form..?
ransok - Saturday, June 14, 2014 9:40 AM:
Thank you Pankaj,
Relationship name and Tab label are same "Cleaning Activities". The 'classification' field is on the same form.
pankaj - Monday, June 30, 2014 3:33 AM:
Hi Ransok,
Since i was busy with my work. It took me long time to reply.
Well i am back with result.
Since Tab will be hidden, You cant set to true with the "name". You have set to true using Id("RelationshipType ID").
if (recp_type)
{
if(recp_type!="Cleaning")
{
top.showPartTabsByBusinessLogic = function()
{
var tabbar = parent.relationships.relTabbar;
var cleaning_act = "52866988885588855566639853698256"; // Dont use "RealtionshipType name" , instead use "RealtionshipType Id".
if(cleaning_act)
{
tabbar.setTabVisible(cleaning_act,true);
}
};
setTimeout("top.showPartTabsByBusinessLogic();", 30);
return;
}
}
Hope this solution will help.
Pankaj B