Reputation: 13
Issue: We would like to change a warning message to an error message on the Sales Order Entry screen SO301000. The warning in particular we want to change is when the Line Item Quantity will take the Available Quantity negative. Currently it is a yellow warning message, but we would like it to be a Red Error.
I am a programmer, but new to Acumatica. I have been through the courses but this particular situation is not covered.
I was hoping for just a point in the right direction to get started. I will take it from there. Appreciate any guidance.
Upvotes: 1
Views: 424
Reputation: 8278
Try using method PXUIFieldAttribute.GetWarning
to obtain the warning message. And then use PXUIFieldAttribute.SetError
to set the error.
Example:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
const string targetWarning = "Target Warning Message";
string warning = PXUIFieldAttribute.GetWarning<SOLine.orderQty>(sender, e.Row);
if (warning?.Contains(targetWarning) == true)
PXUIFieldAttribute.SetError<SOLine.orderQty>(sender, e.Row, warning);
else
PXUIFieldAttribute.SetError<SOLine.orderQty>(sender, e.Row, null);
}
}
Upvotes: 1
Reputation: 186
Try this:
public class Ext_SOOrderEntry : PXGraphExtension<SOOrderEntry>
{
public void SOLine_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e, PXRowUpdated del)
{
del?.Invoke(sender, e);
if (e.Row == null)
return;
const string targetWarning = "quantity available will go negative";
string warning = PXUIFieldAttribute.GetWarning<SOLine.orderQty>(sender, e.Row);
if (!string.IsNullOrEmpty(warning)
&& warning.Contains(targetWarning))
{sender.RaiseExceptionHandling<SOLine.orderQty>(e.Row,
((SOLine)e.Row).OrderQty,
new PXSetPropertyException(warning,
PXErrorLevel.Error));
}
}
public void SOLine_Availability_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e, PXFieldSelecting del)
{
del?.Invoke(sender, e);
if (e.Row == null)
return;
const string targetWarning = "quantity available will go negative";
string warning = PXUIFieldAttribute.GetWarning<SOLine.orderQty>(sender, e.Row);
if (!string.IsNullOrEmpty(warning)
&& warning.Contains(targetWarning))
{
sender.RaiseExceptionHandling<SOLine.orderQty>(e.Row,
((SOLine)e.Row).OrderQty,
new PXSetPropertyException(warning,
PXErrorLevel.Error));
}
}
}
Upvotes: 1