Solved

Set attribute invisible

  • 3 November 2020
  • 23 replies
  • 634 views

Userlevel 2

I’m trying to set an attribute invisible using this line of code :
 

var row = (SOLine)e.Row; 
if(row != null)
{
                var rowExtension = row.GetExtension<Objects.SO.SOLineExt>();
                PXUIFieldAttribute.SetVisible<rowExtension.UsrStkDispEntrp>(cache,row,false);
 }  

 

but i’m getting this error : 

'rowExtension' is a variable but is used like a type

 

thanks.

icon

Best answer by Naveen Boga 3 November 2020, 18:07

View original

23 replies

Userlevel 5
Badge +2

‘rowExtension’ is a variable of the type ‘Objects.SO.SOLineExt’

Generic parameter like the one for SetVisible method requires a Type identifier:

PXUIFieldAttribute.SetVisible<Type>

In your example that should be:

PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp>

 

 

Userlevel 2

‘rowExtension’ is a variable of the type ‘Objects.SO.SOLineExt’

Generic parameter like the one for SetVisible method requires a Type identifier:

PXUIFieldAttribute.SetVisible<Type>

In your example that should be:

PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp>

 

 

I got this error : 

The type name 'UsrCoutUnitEntrp' does not exist in the type 'SOLineExt'
Userlevel 5
Badge +2

The error suggests the code you tried is not equivalent to the solution I suggested.

Notice that the field is named ‘usrStkDispEntrp’ and starts with lowercase ‘u’ in my answer.

PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp>

 

In your error message, the error is on a different field 'UsrCoutUnitEntrp' and it starts with a uppercase letter ‘U’.

Userlevel 7
Badge +10

@SadokHanini did you enter UsrCoutUnitEntrp or usrCoutUnitEntrp? C# is case sensitive, and Acumatica uses both camel-cased and pascal-cased naming in data access classes.

Userlevel 7
Badge +17

@SadokHanini  The error is showing field “UsrCoutUnitEntrp” code NOT provided above.

Can you please share the event code here? We can look and help you if we found anything.

 

 

Userlevel 2

@SadokHanini  The error is showing field “UsrCoutUnitEntrp” code NOT provided above.

Can you please share the event code here? We can look and help you if we found anything.

 

 

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using PX.CCProcessingBase;
using PX.Common;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.DR;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects.TX;
using POLine = PX.Objects.PO.POLine;
using POOrder = PX.Objects.PO.POOrder;
using System.Threading.Tasks;
using PX.CarrierService;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.CCPaymentProcessing.Common;
using PX.Objects.AR.CCPaymentProcessing.Helpers;
using PX.Objects.AR.CCPaymentProcessing.Interfaces;
using ARRegisterAlias = PX.Objects.AR.Standalone.ARRegisterAlias;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Objects.IN.Overrides.INDocumentRelease;
using PX.CS.Contracts.Interfaces;
using Message = PX.CarrierService.Message;
using PX.TaxProvider;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.Extensions.PaymentTransaction;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.Common.Bql;
using PX.Objects;
using PX.Objects.SO;

namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
  {
    #region Event Handlers

    protected void SOLine_RowSelecting(PXCache cache, PXRowSelectingEventArgs e)
    {
      
      var row = (SOLine)e.Row;
      
      if(row != null)
      {
                var rowExtension = row.GetExtension<Objects.SO.SOLineExt>();
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.UsrCoutUnitEntrp> (cache,row,false);
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.UsrStkDispEntrp> (cache,row,false);
        
             
      }  
      
    }
      
    #endregion
  }
}

Userlevel 2

@SadokHanini did you enter UsrCoutUnitEntrp or usrCoutUnitEntrp? C# is case sensitive, and Acumatica uses both camel-cased and pascal-cased naming in data access classes.

I did enter UsrCoutUnitEntrp.

Userlevel 7
Badge +17

Hi @SadokHanini 

As suggested above, DAC fields are case sensitive, please use the below code. If you still getting an issue, please share the SOLineExt code as well.

 

  if(row != null)
      {
                SOLineExt rowExtension = row.GetExtension<SOLineExt>();
                PXUIFieldAttribute.SetVisible<SOLineExt.usrCoutUnitEntrp> (cache,row,false);
                PXUIFieldAttribute.SetVisible<SOLineExt.usrStkDispEntrp> (cache,row,false);    
             
      }  

Userlevel 5
Badge +2

You need to use the Type identifier which starts with a lowercase ‘u’:
PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp> (cache,row,false);
PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp> (cache,row,false);

Instead of the DAC field Value identifier which start with an uppercase ‘U’:
PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.UsrCoutUnitEntrp> (cache,row,false);
PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.UsrStkDispEntrp> (cache,row,false);

Userlevel 7
Badge +17

Hi @SadokHanini ,

All these Enable/Visible stuff recommended writing in the SOLine_RowSelected event, instead of the SOLine_RowSelecting event.

 

Userlevel 2

Hi @SadokHanini ,

All these Enable/Visible stuff recommended writing in the SOLine_RowSelected event, instead of the SOLine_RowSelecting event.

 

thanks :)  
i tried this code but it’s not working the attribute still visible

Fyi : i dont have any compilation error


using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using PX.CCProcessingBase;
using PX.Common;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.DR;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects.TX;
using POLine = PX.Objects.PO.POLine;
using POOrder = PX.Objects.PO.POOrder;
using System.Threading.Tasks;
using PX.CarrierService;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.CCPaymentProcessing.Common;
using PX.Objects.AR.CCPaymentProcessing.Helpers;
using PX.Objects.AR.CCPaymentProcessing.Interfaces;
using ARRegisterAlias = PX.Objects.AR.Standalone.ARRegisterAlias;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Objects.IN.Overrides.INDocumentRelease;
using PX.CS.Contracts.Interfaces;
using Message = PX.CarrierService.Message;
using PX.TaxProvider;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.Extensions.PaymentTransaction;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.Common.Bql;
using PX.Objects;
using PX.Objects.SO;

namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
  {
    #region Event Handlers

    protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
    {
      
      var row = (SOLine)e.Row;
      
      if(row != null)
      {
                //var rowExtension = row.GetExtension<Objects.SO.SOLineExt>();
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp> (cache,row,false);
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp> (cache,row,false);
        
             
      }  
      
    }


    #endregion
  }
}

Userlevel 2

You need to use the Type identifier which starts with a lowercase ‘u’:
PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp> (cache,row,false);
PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp> (cache,row,false);

Instead of the DAC field Value identifier which start with an uppercase ‘U’:
PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.UsrCoutUnitEntrp> (cache,row,false);
PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.UsrStkDispEntrp> (cache,row,false);

Thanks :) 
but the attribute still visible :(

Userlevel 2

the purpose of this dev is to make visible/invisible this two attributes depending on the company that i’m connected 

Userlevel 5
Badge +2

You can try calling the base method first, maybe it’s reverting the visibility changes:

protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
{
    if (del != null)
    {
        del(cache, e);
    }
    
    var row = (SOLine)e.Row;
      
    if(row != null)
    {
        PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp> (cache,row,false);
        PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp> (cache,row,false);     
    }
}    

 

If using a recent Acumatica version, it’s possible the new workflow feature reverts your change too:

https://www.acumatica.com/media/2020/07/2020-Workflow-Engine-final.pdf

Userlevel 7
Badge +17

Hi @SadokHanini 

The below code is working for me. This may help you.. just check it out.

 

  protected virtual void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(cache, e);
            SOLine row = e.Row as SOLine;
            if (row == null) return;

            if (Base.Document.Current != null)
            {

                PXUIFieldAttribute.SetVisible<SOLineAMIOEExt.usrKNAMIOERefundQty>(cache, row, Base.Document.Current.Status == SOOrderStatus.Completed && (row.OrderType == "PH" || row.OrderType == "WO"));
                PXUIFieldAttribute.SetVisible<SOLineAMIOEExt.usrKNAMIOEReasonCode>(cache, row, Base.Document.Current.Status == SOOrderStatus.Completed && (row.OrderType == "PH" || row.OrderType == "WO"));

}

}

Userlevel 2

Hi @SadokHanini 

The below code is working for me. This may help you.. just check it out.

 

  protected virtual void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(cache, e);
            SOLine row = e.Row as SOLine;
            if (row == null) return;

            if (Base.Document.Current != null)
            {

                PXUIFieldAttribute.SetVisible<SOLineAMIOEExt.usrKNAMIOERefundQty>(cache, row, Base.Document.Current.Status == SOOrderStatus.Completed && (row.OrderType == "PH" || row.OrderType == "WO"));
                PXUIFieldAttribute.SetVisible<SOLineAMIOEExt.usrKNAMIOEReasonCode>(cache, row, Base.Document.Current.Status == SOOrderStatus.Completed && (row.OrderType == "PH" || row.OrderType == "WO"));

}

}

thanks :)

I dont know what im doing wrong, still not working 

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using PX.CCProcessingBase;
using PX.Common;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.DR;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects.TX;
using POLine = PX.Objects.PO.POLine;
using POOrder = PX.Objects.PO.POOrder;
using System.Threading.Tasks;
using PX.CarrierService;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.CCPaymentProcessing.Common;
using PX.Objects.AR.CCPaymentProcessing.Helpers;
using PX.Objects.AR.CCPaymentProcessing.Interfaces;
using ARRegisterAlias = PX.Objects.AR.Standalone.ARRegisterAlias;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Objects.IN.Overrides.INDocumentRelease;
using PX.CS.Contracts.Interfaces;
using Message = PX.CarrierService.Message;
using PX.TaxProvider;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.Extensions.PaymentTransaction;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.Common.Bql;
using PX.Objects;
using PX.Objects.SO;

namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
  {
    #region Event Handlers

    protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e,PXRowSelected InvokeBaseHandler)
    {
      
       InvokeBaseHandler?.Invoke(cache, e);
        
       var row = (SOLine)e.Row;
      
       if(row != null)
       {
                //var rowExtension = row.GetExtension<Objects.SO.SOLineExt>();
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp> (cache,row,false);
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp> (cache,row,false);

                //InventorySummaryEnquiryResult
                var query = new PXSelectReadonly<InventorySummaryEnquiryResult>(new PXGraph()).Select<InventorySummaryEnquiryResult>().Where(s => s.SiteID == 13).FirstOrDefault();

            }

    }


    #endregion
  }
}

Userlevel 7
Badge +17

Hi @SadokHanini,

I figured out… Please add the below code in the SOOrderEntryExtension graph.  

 

  protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(cache, e);
            var row = (SOLine)e.Row;
            if (row != null)
            {
                //var rowExtension = row.GetExtension<Objects.SO.SOLineExt>();
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp>(cache, row, false);
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp>(cache, row, false);
            }
        }

        protected virtual void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(cache, e);
            SOOrder row = e.Row as SOOrder;
            PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp>(Base.Transactions.Cache, null, false);
            PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp>(Base.Transactions.Cache, null, false);
        }
 

 

Hope this code will solve your problem.

Best Regards,
Naveen B

Userlevel 5
Badge +1

Hi @SadokHanini,

You should not use PXSelectReadonly for Non-DB objects. Use PXSelect. 

            //InventorySummaryEnquiryResult
                var query = new PXSelectReadonly<InventorySummaryEnquiryResult>(new PXGraph()).Select<InventorySummaryEnquiryResult>().Where(s => s.SiteID == 13).FirstOrDefault();

 

Below link is the same thing that you have asked for the resolution.

https://community.acumatica.com/customizations-147/retrieve-data-from-inventorysummaryenquiryresult-3977?postid=8280#post8280

 

Fix this and check again.  

Userlevel 2

Hi @SadokHanini,

You should not use PXSelectReadonly for Non-DB objects. Use PXSelect. 

            //InventorySummaryEnquiryResult
                var query = new PXSelectReadonly<InventorySummaryEnquiryResult>(new PXGraph()).Select<InventorySummaryEnquiryResult>().Where(s => s.SiteID == 13).FirstOrDefault();

 

Below link is the same thing that you have asked for the resolution.

https://community.acumatica.com/customizations-147/retrieve-data-from-inventorysummaryenquiryresult-3977?postid=8280#post8280

 

Fix this and check again.  

i tried with PXselect same problem

Userlevel 2

Hi @SadokHanini,

I figured out… Please add the below code in the SOOrderEntryExtension graph.  

 

  protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(cache, e);
            var row = (SOLine)e.Row;
            if (row != null)
            {
                //var rowExtension = row.GetExtension<Objects.SO.SOLineExt>();
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp>(cache, row, false);
                PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp>(cache, row, false);
            }
        }

        protected virtual void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(cache, e);
            SOOrder row = e.Row as SOOrder;
            PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrCoutUnitEntrp>(Base.Transactions.Cache, null, false);
            PXUIFieldAttribute.SetVisible<Objects.SO.SOLineExt.usrStkDispEntrp>(Base.Transactions.Cache, null, false);
        }
 

 

Hope this code will solve your problem.

Best Regards,
Naveen B

Manyyyy thanks :) its working !! 

Userlevel 7
Badge +17

Hi @SadokHanini 

Great !!!   Thanks a lot for the update. :) 

Userlevel 7
Badge +17

Hi @SadokHanini,

You want to get the QtyAvailable value based on the warehouse and inventory?

If yes, the below code will help you to get the QtyAvailable value from the database

 

 PXSelectGroupBy<INSiteStatus, Where<INSiteStatus.inventoryID, Equal<Required<INSiteStatus.inventoryID>>>,                                                              Aggregate<GroupBy<INSiteStatus.inventoryID, Sum<INSiteStatus.qtyAvail>>>                                     .Select(graph, row.InventoryID);

 

NOTE: It is NOT recommended to write the BQL queries in RowSelected Event

 

Best Regards,
Naveen B

Userlevel 4
Badge

If you need to hide a form column based on another field selection, here is the code for that below.  I took what Naveen did and simply edited it for a conditional situation.

        protected virtual void CRCase_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
          {
            InvokeBaseHandler?.Invoke(cache, e);
            var row = (CRCase)e.Row;
            if (row != null)
              {
                if (row.CaseClassID == "CAM")
                  {
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrRMAReason>(cache, row, false);
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrSupportCategory >(cache, row, false);
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrContractDesc>(cache, row, false);
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrCaseStage>(cache, row, false);    
                  }
              }
            
          }

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