Solved

Need To validate Unit Price field in Sales Order Screen


Userlevel 3
Badge

I need to show an error message when unit price is 0  in sales order line details.

User can upload the sales order line details from excel into sales order screen and according to the inventory item unit price is automatically capture from arsales form.

I add fieldverifing event below like that.

protected void SOLine_CuryUnitPrice_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e, PXFieldVerifying baseMethod)
{

SOLine row = e.Row as SOLine;
if (row.CuryUnitPrice == 0)
{
throw new PXSetPropertyException("Unit Price should not be 0");
}

}

After uploading so line from excel ,If condition is true or false error message is shown.

 

icon

Best answer by jeewanishalika20 11 July 2023, 09:41

View original

12 replies

Userlevel 7
Badge +17

@jeewanishalika20  Can you please try with below code?

 

 protected virtual void SOLine_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting InvokeBaseHandler)
{
InvokeBaseHandler(cache, e);
SOLine row = (SOLine)e.Row;
if (row != null && row.CuryUnitPrice == 0m)
{
string msg = "Unit Price must be greater than 0";
cache.RaiseExceptionHandling<SOLine.curyUnitPrice>(row, row.CuryUnitPrice, new PXSetPropertyException(msg, PXErrorLevel.Error));
}
}

 

Userlevel 3
Badge

Hi @Naveen Boga ,

after adding above this ,if the unit price is zero error is not show.

 

Userlevel 7
Badge +17

@jeewanishalika20  Can you confirm, after SAVE also it did not show any error?

Userlevel 3
Badge

Hi @Naveen Boga ,

 

after saving, error is showed on the 1st row

 

Userlevel 3
Badge

Hi @Naveen Boga ,

before the saving lines are showed below like that.

When saving, error is showed on the 1st row.But, Unit price field is changed from 0 to 12.

 

Userlevel 7
Badge +17

@jeewanishalika20  In which version you are checking this?

Userlevel 3
Badge

Hi @Naveen Boga ,

Acumatica ERP 2022 R2 version

Userlevel 7
Badge +17

@jeewanishalika20  The same code is working properly for the Order Qty field but not for the Unit Price field. Not sure what is the reason.

I suggest you to raise a support case on this to know the root cause for this.

 

 

Userlevel 3
Badge

Hi @Naveen Boga ,

I will raised a ticket.Thank you for the support

Userlevel 7
Badge +17

@jeewanishalika20  Thank you, please share the update once you receive the root cause details.

Userlevel 3
Badge

Hi 

I found the correct answer .

protected void SOLine_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting baseHandler)

{

baseHandler?.Invoke(cache, e);

var row = (SOLine)e.Row;

if (row == null) return;

if (row.CuryUnitPrice == 0 && row.IsFree == false)

{


PXUIFieldAttribute.SetError<SOLine.curyUnitPrice>(cache, row, "Unit Price should not be 0");

}

}

 

Userlevel 7
Badge

Thank you for sharing your solution with the community @jeewanishalika20!

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