How to hide Relationship Tabs based on Business Logic ARAS Field Services

Transcription

How to hide Relationship Tabs based on Business Logic ARAS Field Services
ARAS Field Services
Knowledge Circular
Access: Community
Category: Innovator Customizing
Status: RELEASED
Id: KB-000104
Dated:18.11.2008 08:48
How to hide Relationship Tabs based on
Business Logic
Overview
A solution will be presented on conceptual level and in form of a working example.
You will have to adapt the various elements to your needs and business logic.
The example shown here also got added to the BasicsDemo902 BL6 environment, you can download
from www.aras.com/projects to see it working.
Conceptual
A simple way to hide item relationships based on conditions of the item (by permission, by user
identity, by) is currently not available as Innovator administration parameter.
On the other hand, rules that define when to show or hide a relationship tab can become quite
complex quickly. An thus will require customer-specific add-ons any ways.
Which means, this will have to be done with scripts in Innovator.
Client-side or Server-Side ?
Although controlling content to be displayed inside the client is best controlled by server-side
methods (i.e. OnAfterGet, to filter the AML sent to the client ), in this case it is not this simple. The
ARAS Innovator standard client (release 9.0x) does not have a way of telling to only show relationship
data sent via AML. Rather it will display all relationship tabs as defined by the ItemType definition.
This means we will have to hide relationship tabs on forms level (after the data got sent to the
client), by a client-side method attached to the onFormPopulated form-event.
Because there is some timing involved when relationship tabs are rendered on the form, we had to
include a timer function to make sure all relationships of a given IemType are loaded before we can
apply the business logic to hide some of them. ( in the sample we use:
setTimeout("top.hidePartTabsByBusinessLogic();", 30)
The following example will show how to add a simple business logic for hiding tabs to the “Part
form”.
Copyright © 2008 Aras Corporation
How to hide RelationshipTab based on Business Logic KB-000104 -v1
1 of 4
ARAS Field Services
How to hide Relationship Tabs based on Business Logic
Access: Community
Status: RELEASED
Id: KB-000104
NOTE: For simplicity the method code in this example does not support multi-language forms.
Identifying a relationship tab is done by its “label”. For multi-language forms you will need to add
logic to identify tabs by different languages.
Example
In this example we add business logic to the parts form.
1. On Admin TOC go to “Forms” and open the form “Part” and lock it to prepare to make
changes
2. Go to tab “Form events” and add a new method with the name
“HidePartTabsByBusinessLogic”. Then set its event to “onFormPopulated”
3. If there are other methods listed for the “onFormPopulated” event, set the order of this one
to be last.
4. Edit (View) this new client-side method and paste the JavaScript provided below and save the
method.
5. Adapt the business-logic to hide different tabs by classification of parts (array:
hideTabsByClass) to match you part’s classifications and the part’s tab labels.
6. Save and close the form “Part”
7. Log-off and -On again. Search for “Parts” and open an item to see that i.e. “make” parts do
not have the tab “Vendor List”
The simple logic of this example is:
If Part classification is “Assembly”, then hide tabs: Planning Documents,Goals
If Part classification is “Component”, then hide tabs: Planning Documents,Goals,BOM,Multi-Level
BOM
And, independent of classification, if the part’s make_buy property = “Make”, then hide the tab:
“Vendors List” OR “AML”
Copyright © 2008 Aras Corporation
How to hide RelationshipTab based on Business Logic KB-000104 -v1
2 of 4
ARAS Field Services
How to hide Relationship Tabs based on Business Logic
Access: Community
Status: RELEASED
Id: KB-000104
// client-side method: HidePartTabsByBusinessLogic
//
// Form: Part (Part component)
// Form Event: OnFormPopulated
// Filed Event: OnChange of "classification" field
//
// Logic: array lookupClasses defines the sub-classifications of Part to which
hiding tabs will be applied
//
for classes not listed in the array, all tabs will be
shown
//
array hideTabsByClass lists tabs to be hidden per sub-classification
// addl logic: if make_buy is not "buy" always hide the "Vendors List" tab
//
// This sample code is adapted to work with the BasicsDemo database
// You need to adapt it to your own logic and use cases
//
// In multi-language environments this code need to be adapted !!! tab names will
be language specific
//
// Last modified: 30-Aug-2008
// A separate function and setTimeouts are necessary because the relationships
frame might not be
// fully loaded when the event is initially fired
top.hidePartTabsByBusinessLogic = function() {
// If the tabbar is not yet ready, wait a bit and call the function recursively
if (!parent.relationships || !parent.relationships.relTabbarReady ||
parent.relationships.relTabbar.GetTabOrder("|") === "" ) {
setTimeout("top.hidePartTabsByBusinessLogic();", 30);
return;
}
// Get the value of the classification property from the form
var thisClass = new String(document.thisItem.getProperty("classification",""));
// Get the value of make_buy for special treatment below
var Make_Buy = new String(document.thisItem.getProperty("make_buy",""));
// debug alert(thisClass);
var tabbar = parent.relationships.relTabbar;
var hideTabsByClass = new Array();
// register Class names to check
var lookupClasses = new Array("Assembly","Component", "Sellable Item");
// for 2nd array make sure you use the right index for classes: 0 = Assembly, 1=
Components etc.
// ### Assembly tabs to hide
Copyright © 2008 Aras Corporation
How to hide RelationshipTab based on Business Logic KB-000104 -v1
3 of 4
ARAS Field Services
How to hide Relationship Tabs based on Business Logic
Access: Community
Status: RELEASED
Id: KB-000104
hideTabsByClass[0] = new Object();
hideTabsByClass[0] = new Array("Quality Planning Documents","Goals");
// ### Component tabs to hide (class path has component not on leaf level)
hideTabsByClass[1] = new Object();
hideTabsByClass[1] = new Array("Quality Planning Documents","Goals","BOM","MultiLevel BOM");
// ### Sellable Item tabs to hide
hideTabsByClass[2] = new Object();
hideTabsByClass[2] = new Array("Alternates");
// Hide the tabs listed in above arrays
for(i=0; i < lookupClasses.length; i++){
if (thisClass.indexOf(lookupClasses[i]) > -1) {
// Class found
for(j=0; j < hideTabsByClass[i].length; j++){
// Get the id of the tab using its label (the id of the tab is the same as
the id of the RelationshipType)
tabID = tabbar.GetTabId(hideTabsByClass[i][j]);
if (tabID !== null && tabID !== 0) {
// tab to hide found
tabbar.SetTabVisible(tabID,false);
}
}
}
}
// ### over riding rule:
// if tab is "Vendors List" AND Make_Buy property is NOT "Buy", hide the tab
tabID = tabbar.GetTabId("Vendors List");
if (tabID !== null && tabID !== 0 && Make_Buy != "Buy") {
tabbar.SetTabVisible(tabID,false);
}
// OR if tab is "AML" AND Make_Buy property is NOT "Buy", hide the tab
tabID = tabbar.GetTabId("AML");
if (tabID !== null && tabID !== 0 && Make_Buy != "Buy") {
tabbar.SetTabVisible(tabID,false);
}
};
setTimeout("top.hidePartTabsByBusinessLogic();", 30);
Copyright © 2008 Aras Corporation
How to hide RelationshipTab based on Business Logic KB-000104 -v1
4 of 4