Skip to main content
Solved

Sales Quotes - Unable to Update the Unit Price Field

  • February 10, 2023
  • 3 replies
  • 148 views

Forum|alt.badge.img

Hello Community,

I’m trying to update the Unit Price field when I update the Quantity but it is not working but the same code is working in the Sales Orders screen. 

Not sure why it is not working in the Sales Quotes screen. Below is the simple code I’m using but still not working, can anyone review and help on this?

 

public class QuoteMaintExt : PXGraphExtension<QuoteMaint>
    {
        public static bool IsActive() => true;
        protected virtual void CROpportunityProducts_Quantity_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseMethod)
        {
            InvokeBaseMethod?.Invoke(cache, e);
            CROpportunityProducts row = e.Row as CROpportunityProducts;



            if (row != null)
            {
                cache.SetValueExt<CROpportunityProducts.curyUnitPrice>(row, 10m); 
            }
        }
    }

 

Best answer by Yuriy Zaletskyy

What about this approach:

    public class QuoteMaintExt : PXGraphExtension<QuoteMaint>
    {
        public static bool IsActive() => true;

        protected virtual void _(Events.RowUpdated<CROpportunityProducts> e)
        {
            var nR = e.Row;
            var oR = e.OldRow;
            if (nR.InventoryID != oR.InventoryID) // InventoryID was changed
            {
                nR.CuryUnitPrice = 15;
            }

        }

    }

with provided code sample, setting of CuryUnitPrice will happen, if InventoryID was updated.

View original
Did this topic help you find an answer to your question?

3 replies

Yuriy Zaletskyy
Jr Varsity I
Forum|alt.badge.img+3

Yeah, that is tricky one. 

Reason why your code doesn’t work for Sales quote is plenty of attributes, which applied to curyUnitPrice by Acumatica itself. Below goes one example:

        [PXDefault(TypeCode.Decimal, "0.0")]
        [PXDBCurrencyPriceCost(typeof(CROpportunityProducts.curyInfoID), typeof(CROpportunityProducts.unitPrice))]
        [PXUIField(DisplayName = "Unit Price", Visibility = PXUIVisibility.SelectorVisible)]
        public virtual Decimal? CuryUnitPrice { get; set; }

and that is far from the only one. I’ve tried initially to use CacheAttached, and remove section PXDBCurrencyPriceCost, but it didn’t work, some additional overridings may be needed to apply. So instead, I’d suggest to use one level higher, and go with RowUpdated:

    public class QuoteMaintExt : PXGraphExtension<QuoteMaint>
    {
        public static bool IsActive() => true;

        protected virtual void _(Events.RowUpdated<CROpportunityProducts> e)
        {
            var nR = e.Row;
            nR.CuryUnitPrice = 15;
        }

    }

on my machine worked perfectly fine:

 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 55 replies
  • February 12, 2023

Hi @Yuriy Zaletskyy  I have tried with the RowUpdated event and verified it is working fine but if I wanted to change the UnitPrice for reason, system will not allow this.

Hence I would like to affect the UnitPrice only when InventoryID is added. 

 

 


Yuriy Zaletskyy
Jr Varsity I
Forum|alt.badge.img+3

What about this approach:

    public class QuoteMaintExt : PXGraphExtension<QuoteMaint>
    {
        public static bool IsActive() => true;

        protected virtual void _(Events.RowUpdated<CROpportunityProducts> e)
        {
            var nR = e.Row;
            var oR = e.OldRow;
            if (nR.InventoryID != oR.InventoryID) // InventoryID was changed
            {
                nR.CuryUnitPrice = 15;
            }

        }

    }

with provided code sample, setting of CuryUnitPrice will happen, if InventoryID was updated.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings