
Hello,
I have a form and many tabs in it. In the general tab, I select primary asset type( reference group I mean lookup) and asset type(enum). I need to hide and display some of the tabs based on the selection of both primary asset types and asset types. I wrote a code for this (I use OnModified event to select Primary asset Type) and I can hide or display tabs based on the selection of primary asset type but I am not sure how do I add those code selections of asset types, too.
If someone can help me with this I would be really appreciated it.
[FormDataFieldEventHandler(formDataFieldStr(EntAssetObjectTable, FixedAsset, PrimaryAssetType), FormDataFieldEventType::Modified)]
public static void PrimaryAssetType_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
FormDataSource dataSource = sender.datasource();
EntAssetObjectTableFormDataFieldEvent::UpdateTab(dataSource);
}
///
///
///
///
///
[FormDataSourceEventHandler(formDataSourceStr(EntAssetObjectTable, FixedAsset), FormDataSourceEventType::Activated)]
public static void FixedAsset_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
EntAssetObjectTableFormDataFieldEvent::UpdateTab(sender);
}
public static void UpdateTab(FormDataSource sender)
{
FixedAsset fixedAsset = sender.cursor();
FormRun formRun = sender.formRun() as FormRun;
FormControl le = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabA));
FormControl pg = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabB));
FormControl c = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabC));
FormControl d = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabD));
FormControl e = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabE));
a.visible(false);
e.visible(false);
c.visible(false);
b.visible(false);
e.visible(false);
var primary = PrimaryAssetType_WM::findByRecId(fixedAsset.PrimaryAssetType);
var type = FixedNonFixedSelectionBaseEnum_WM::NonFixedAssets;
switch(primary.Code)
{
case 'x':
a.visible(true);
break;
case 'y':
b.visible(true);
break;
case 'z':
c.visible(true);
d.visible(true);
break;
case 't':
e.visible(true);
a.visible(true);
break;
}
Thanks, regards...
I did not fully understand the problem. Let's talk about single-field control first;
I see that you use both OnActivated and OnModified in the code. Actually you have to write in OnActivated, not OnModified. Why did you use OnModified? OnActivated wasn't enough?
If we talk for two fields, instead of filling the enable value as true/false directly, you should keep it in a boolean variable.
You may then concatenate with the value from the enum
Or you can create branchs with enum as a second condition inside the switch case.
Since we do not know the relationship between the two data, it is difficult to say for sure. If you show your expectations with examples, we can help you combine the two terms.