Solved

PX1070 - is the message misleading?

  • 27 January 2023
  • 1 reply
  • 28 views

Userlevel 7
Badge +5

I have this code that is used to determine if a field on a row is enabled based on the value of another field on the same row.  If the value if the first field changes, that can change the enabled status of the second field.
 

protected void _(Events.FieldSelecting<MyDAC, MyDAC.secondField> e, PXFieldSelecting baseMethod )
{
if (baseMethod != null )
{
baseMethod(e.Cache, e.Args);
}

MyDAC row = e.Row;
if (row != null)
{
if (row.firstField == true)
{
PXUIFieldAttribute.SetEnabled<MyDAC.secondField>(e.Cache, row, false);
}
}
}

However, the PXUIFieldAttribute line of code shows an error PX1070: The state of fields and actions can be configured only in the RowSelected event handler.

This code will compile and it works. So my question is, is the logic used to trigger the PX1070 incorrect?  Or is there a more correct way to achieve this goal? Or do I just ignore PX1070 in this case?

icon

Best answer by Dmitrii Naumov 27 January 2023, 23:26

View original

1 reply

Userlevel 7
Badge +5

Acuminator errors are frequently about the best practices and not about code not being able to compile. 

The best practice is to put the logic in RowSelected, because that way you guarantee it to be triggered in 100% of cases when a record is displayed. 

I think the way you have it here may result in incorrectly set enabled status when you change the value of the firstField, but the system does not explicitly reselect the secondField for some reason.

It may be a rare edge case or may not be possible at all, depending on the fields’ positions on the screen.

However, I’d still suggest you to move the logic to RowSelected to be sure it’s 100% correct and for other devs to know where to look for enabling/disabling logic.

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