Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / disabling menu item ba...
Finance forum
Suggested answer

disabling menu item bassed on condition

Posted on by 248
Hi,

I added a menu item on SalesLine grid in 'both salesTable' form and 'ProjSalesItemReq' form. Where these two forms have "SalesTable" and "SalesLine" as datasources

I want this menu item to be enabled only if SalesTable.SalesStatus = backOrder

is the only way to do it on active method for for salesLine datasource on both forms? just trying to see if there is another way than what i did, which will save calling the logic each time on active method for salesLine even though i'm checking SalesTable status
[ExtensionOf(formDataSourceStr(SalesTable, SalesLine))]
final class SalesTableSalesLineFormDS_Extension
{
    public int active()
 {
     int ret = next active();

     if(ret)
     {
         FormDataSource salesTableDataSource = element.dataSource(formDataSourceStr(SalesTable, SalesTable)) as FormDataSource;         
         SalesTable  salesTable  = salesTableDataSource.cursor();

         if(salesTableDataSource && salesTable && salesTable.SalesStatus == SalesStatus::Backorder)
         {
             element.design().controlName(formControlStr(SalesTable,XMenu)).enabled(true);
         }
         else
         {
             element.design().controlName(formControlStr(SalesTable,XMenu)).enabled(false);
         }
         
     }
     return ret;
 }
}
 
[ExtensionOf(formDataSourceStr(ProjSalesItemReq, SalesLine))]
final class ProjSalesItemReqFormDS_Extension
{
    public int active()
 {
     int ret = next active();

     if(ret)
     {
         FormDataSource salesTableDataSource = element.dataSource(formDataSourceStr(ProjSalesItemReq, SalesTable)) as FormDataSource;         
         SalesTable  salesTable  = salesTableDataSource.cursor();

         if(salesTableDataSource && salesTable && salesTable.SalesStatus == SalesStatus::Backorder)
         {
             element.design().controlName(formControlStr(ProjSalesItemReq,XMenu)).enabled(true);
         }
         else
         {
             element.design().controlName(formControlStr(ProjSalesItemReq,XMenu)).enabled(false);
         }
         
     }
     return ret;
 }
}
 
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 3,904 on at
    disabling menu item bassed on condition
    Hi,
     
    Since your condition logic depends on SalesTable then I recommend you add it on the active and init method of SalesTable data source.
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans