Skip to main content
Answer

Need To validate Unit Price field in Sales Order Screen

  • June 29, 2023
  • 12 replies
  • 159 views

Forum|alt.badge.img

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.

 

Best answer by jeewanishalika20

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");

}

}

 

12 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • June 29, 2023

@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));
}
}

 


Forum|alt.badge.img

Hi @Naveen Boga ,

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

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • June 29, 2023

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


Forum|alt.badge.img

Hi @Naveen Boga ,

 

after saving, error is showed on the 1st row

 


Forum|alt.badge.img

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.

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • June 29, 2023

@jeewanishalika20  In which version you are checking this?


Forum|alt.badge.img

Hi @Naveen Boga ,

Acumatica ERP 2022 R2 version


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • June 29, 2023

@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.

 

 


Forum|alt.badge.img

Hi @Naveen Boga ,

I will raised a ticket.Thank you for the support


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • June 29, 2023

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


Forum|alt.badge.img

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");

}

}

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • July 11, 2023

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