Solved

Cannot hide a custom action button on the Sales Quotes Details Grid

  • 7 August 2023
  • 4 replies
  • 116 views

Userlevel 6
Badge +3

I added a custom action to the Details grid of the Sales Quotes screen.  It works as expected.

If the setup for my module is disabled, I am able to disable the button, but I cannot seem to hide it from view.

These are the ASPX changes to add the button.  

(added to the top of the form:

 <px:PXDSCallbackCommand Name="ResetPrice" Visible="false" CommitChanges="true" DependOnGrid="ProductsGrid" /></CallbackCommands>

 

Toolbar button added in the grid seciton:

 <px:PXToolBarButton Text="Reset Price" Visible="False">
    <AutoCallBack Target="ds" Command="ResetPrice">
      <Behavior CommitChanges="True" /></AutoCallBack>

 

In the RowSelected, I check if my module is enabled.  If it is not, I try to set the Visibility to false.

            if (setup == null || (setup.EnablePricingMarkup == null || setup.EnablePricingMarkup == false) || (setup.UseQuotesOpportunities == null || setup.UseQuotesOpportunities == false))
            {
                PXUIFieldAttribute.SetVisible<CROpportunityProductsExt.usrCurrentCost>(cache, null, false);
                PXUIFieldAttribute.SetVisible<CROpportunityProductsExt.usrQuoteCost>(cache, null, false);
                ResetPrice.SetVisible(false);
                ResetPrice.SetEnabled(false);
                return;
            }

            ResetPrice.SetVisible(true);
            ResetPrice.SetEnabled(true);
 

If my module is not enabled, it is being disabled, but it is still showing on the menu bar of the grid.  Note that even when it is disabled, it is not greyed out.  

If you click it when it is disabled you get a message on the screen.

 

In the project editor, I default Visible to False as well.

If my custom module is not being used, I want to hide this button.

Any ideas on what I am missing?

Edit:  This is the definition of the Action in the graph extension in case I have something wrong there:

        public PXAction<CROpportunityProducts> ResetPrice;
        [PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "Reset Price", Enabled = false, Visibility = PXUIVisibility.Invisible)]
        protected void resetPrice()
        {
            CROpportunityProducts cR = Base.Products.Current;
            if (cR == null) return;

            CROpportunityProductsExt itemExt = PXCache<CROpportunityProducts>.GetExtension<CROpportunityProductsExt>(cR);
            if (itemExt == null) return;

            InventoryItemCurySettings inItem = SelectFrom<InventoryItemCurySettings>.Where<InventoryItemCurySettings.inventoryID.IsEqual<CROpportunityProducts.inventoryID.FromCurrent>>.View.Select(Base);
            if (inItem == null) return;

            cR.CuryUnitPrice = inItem.BasePrice;
            cR.ManualPrice = false;
            itemExt.UsrQuoteCost = 0;

            Base.Products.UpdateCurrent();
        }

 

 

icon

Best answer by davidnavasardyan09 12 August 2023, 16:55

View original

4 replies

Userlevel 7
Badge +17

Hi @Joe Schmucker  Can you please refer the below link 

 

Userlevel 6
Badge +3

@Naveen Boga Thanks for the link.  I was able to get the button to show as disabled on the Sales Quotes screen but not the Opportunities screen by adding the StateField.  Exact same c# code, exact same ASPX code on both screens.  It doesn’t work on the Opportunities screen.

This still does not allow me to hide the button.

The button was a “professional” add on to make the screen better.  Since I cannot hide a custom button, I’m just removing it.  I’ve spent enough time on it.

I appreciate the help anyway.   

Userlevel 5
Badge +1

Hi @Joe Schmucker 

Here are some things to consider and suggestions on how you can hide the button completely:

  1. ASPX Button Visibility: When defining the toolbar button, you've set Visible="False" in the ASPX. This should hide the button by default, but when the Sales Quotes screen loads, Acumatica will then execute the graph and the RowSelected event.

  2. PXUIFieldAttribute Visibility vs PXAction Visibility: The method PXUIFieldAttribute.SetVisible<>() is designed to hide or show DAC fields. For your action button, you should utilize the SetVisible() method associated with PXAction to control its visibility. However, you've already done this with ResetPrice.SetVisible(false); which should work.

  3. Ensure Proper Cache: In your RowSelected event, make sure you're working with the right cache for the event. Your logic seems to be related to an Opportunity product, so ensure the cache passed to the RowSelected event handler is the cache for CROpportunityProducts.

  4. Event Scope: The RowSelected event will fire for each row in the grid. While it's okay to set action button visibility in this event, ensure there are no conflicting logic elsewhere in your graph extension that might be overriding the visibility setting.

  5. Graph Extension Initialization: In some cases, you might want to consider setting the visibility of the button during the graph's initialization (i.e., in the Initialize() method). However, note that this will only set the button's visibility once when the graph is loaded, so if you need to make dynamic decisions based on each record, then the RowSelected event remains the best option.

  6. PXUIField Definition: In your action's PXUIField attribute definition, you have Visibility = PXUIVisibility.Invisible. While this seems correct, there might be some overriding behavior occurring elsewhere. Try commenting out that attribute or the visibility setting within it to see if it makes a difference.

  7. Clear Cache: Acumatica caches compiled versions of screens and their related code. Try clearing your browser cache and also use the "Clear Cache" option under the System menu in Acumatica to ensure you're viewing the latest version of your customization.

  8. Review Customization Order: If you have multiple customizations applied to the same screen, the order in which they're published can affect the final behavior. Review other customizations to ensure there's no conflict or overlapping behavior.

If after checking these points the button is still not hiding, you might want to consider temporarily commenting out sections of your code or making minimal test customizations to isolate the issue. This iterative approach can help narrow down the root cause.

Userlevel 6
Badge +3

@davidnavasardyan09 Wow.  You went above and beyond the call of duty here.  

I had all the items in your checklist as you recommended.  The only thing I didn’t do was override Initialize().

I commented out EVERYTHING except the definition of the Action and added the Initialize() override.  I set the Action to ResetPrice.SetVisible(false);  However, the button still showed.  That made me look at the Action itself.  I found that I had the wrong table.  I changed public PXAction<CROpportunityProducts> ResetPrice; to public PXAction<CRQuote> ResetPrice; 

The button is now hidden when I set visibility to false in RowSelected(). 

Thanks for going the extra mile.  Your suggestions led me to what I needed to do to resolve this.

My kindest regards to you!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved