Solved

Negative Values

  • 20 August 2023
  • 6 replies
  • 141 views

Userlevel 6
Badge +3

Hello community,
I would like to make a field of Int Data Type to not accept negative values. I would like to know if I can define the logics using the Customization project Editor? If not then using VS how shall I load up the file in which i am willing to apply the condition for the particular field?

Thanks in Advance.

icon

Best answer by harutyungevorgyan 21 August 2023, 22:36

View original

6 replies

Badge +11

Is this a custom field or an existing field?

Userlevel 6
Badge +3

Is this a custom field or an existing field?

Its a custom field. But I would also like to know about the existing field.

Userlevel 5
Badge +1

Hello @Harshita 

Using the Customization Project Editor:

  1. Open your Customization Project.
  2. Navigate to the DAC that contains the field you want to modify.
  3. Select the field, and in the field properties, add a PXInt attribute with a MinValue parameter.
  4. In the MinValue parameter, set the minimum value to 0.
  5. Publish the customization.

Here's an example:

 

[PXInt(MinValue = 0)]
[PXUIField(DisplayName = "Custom Field")]
public virtual int? UsrCustomField { get; set; }
public abstract class usrCustomField : PX.Data.BQL.BqlInt.Field<usrCustomField> { }

Using Visual Studio:

  1. Open your customization project in Visual Studio.
  2. Navigate to the DAC that contains the field you want to modify.
  3. Add or modify the attribute for the field, setting the MinValue parameter of the PXInt attribute to 0.
  4. Save the file and publish the customization from the Customization Project Editor in Acumatica.

After applying the customization, the field should no longer accept negative values. When a user tries to input a negative value, they should receive a validation error.

Userlevel 6
Badge +3

Hello @Harshita 

Using the Customization Project Editor:

  1. Open your Customization Project.
  2. Navigate to the DAC that contains the field you want to modify.
  3. Select the field, and in the field properties, add a PXInt attribute with a MinValue parameter.
  4. In the MinValue parameter, set the minimum value to 0.
  5. Publish the customization.

Here's an example:

 

[PXInt(MinValue = 0)]
[PXUIField(DisplayName = "Custom Field")]
public virtual int? UsrCustomField { get; set; }
public abstract class usrCustomField : PX.Data.BQL.BqlInt.Field<usrCustomField> { }

Using Visual Studio:

  1. Open your customization project in Visual Studio.
  2. Navigate to the DAC that contains the field you want to modify.
  3. Add or modify the attribute for the field, setting the MinValue parameter of the PXInt attribute to 0.
  4. Save the file and publish the customization from the Customization Project Editor in Acumatica.

After applying the customization, the field should no longer accept negative values. When a user tries to input a negative value, they should receive a validation error.

Thank you so much @davidnavasardyan09 , for your solution. What I did first is, I just entered the first line as a condition, published the pkg. So now Acumatica doesn’t allow me to even type the negative ‘-’ sign in the field.

 


And upon creating a new field and adding the lines as you suggested, the system displays the following message when trying to publish as shown below. Please let me know what I am missing here. I haven’t created any field with name as Custom2 before.

 


Thanks in advance.

Userlevel 6
Badge +3

I am also looking to add these 2 new fields and display the result in a third custom field.

Hello @Harshita 

Using the Customization Project Editor:

  1. Open your Customization Project.
  2. Navigate to the DAC that contains the field you want to modify.
  3. Select the field, and in the field properties, add a PXInt attribute with a MinValue parameter.
  4. In the MinValue parameter, set the minimum value to 0.
  5. Publish the customization.

Here's an example:

 

[PXInt(MinValue = 0)]
[PXUIField(DisplayName = "Custom Field")]
public virtual int? UsrCustomField { get; set; }
public abstract class usrCustomField : PX.Data.BQL.BqlInt.Field<usrCustomField> { }

Using Visual Studio:

  1. Open your customization project in Visual Studio.
  2. Navigate to the DAC that contains the field you want to modify.
  3. Add or modify the attribute for the field, setting the MinValue parameter of the PXInt attribute to 0.
  4. Save the file and publish the customization from the Customization Project Editor in Acumatica.

After applying the customization, the field should no longer accept negative values. When a user tries to input a negative value, they should receive a validation error.

Thank you so much @davidnavasardyan09 , for your solution. What I did first is, I just entered the first line as a condition, published the pkg. So now Acumatica doesn’t allow me to even type the negative ‘-’ sign in the field.

 


And upon creating a new field and adding the lines as you suggested, the system displays the following message when trying to publish as shown below. Please let me know what I am missing here. I haven’t created any field with name as Custom2 before.

 


Thanks in advance.

Hi @Harshita , just use these attributes to add your fields, you don’t need to define a property or abstract class for these fields. Apparently the reason of this error is that Acumatica has created this property and abstract class for your fields automatically and if you type it manually it seems like duplication. So keep all as shown on your first screenshot and after that if you want to add these fields to screen just go to screens page in your customization editor,find the form Document and place your fields where you want, for searching the fields quickly you can look for only Custom fields.
 

 

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