Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

disabling menu item bassed on condition

(1) ShareShare
ReportReport
Posted on by
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
    8,244 Super User 2025 Season 1 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
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,118 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans