Customizing DAC Attributes
To modify or extend the behavior that is defined within a data access class (DAC), you should append or override the field attributes declared within the DAC.
- The Customer Order data field on the form area (see the screenshot below) must have the None value when the user has not specified the reference number of the customer.
- The values of the Discount Percent column must be limited to a range of -30 to 25 percent instead of the original range of -100 to 100 percent.
To begin implementing the first requirement, inspect the properties of the Customer Order UI control. To do this, on the Customization menu, select Inspect Element and click the box or label of the control on the form. The system should retrieve the following information of the control that will display in the Element Properties dialog box:
- Control Type: Text Edit. The type of the UI control.
- Data Class: ARInvoice. The data access class that contains the inspected field.
- Data Field: InvoiceNbr. The field that is represented by the Customer Order control on the form.
- Business Logic: SOInvoiceEntry. The business logic controller (BLC, also referred to as graph) that provides the logic executed on the Invoices form.
To modify attributes of the DAC field, select Element Properties dialog box. In the Select Customization Project dialog box, specify the project to which you want to add the customization item for the data field and click OK.
in theThe Data Class Editor opens for customization of the InvoiceNbr
field of
the ARInvoice
data access class.
- In the Customize Attributes box select Append to Original.
- In the text area, type
[PXDefault("None")]
. - Save your changes in the Data Class Editor.
The system adds the customized data access class to the Data Access list of project items. For more information, see Customized Data Classes.
To view the changes applied to the Invoices form, publish the customization project and add
a new document on the Invoices form. When you add a new document, the system will insert the
None default value into the Customer Order box as you have
specified with the PXDefault
attribute.
To implement the second requirement of the task, inspect the Discount Percent column on the Document Details tab of the Invoices form. To do this, on the Customization menu, select Inspect Element and click the area of the Discount Percent column header. The system should retrieve the following information of the control that will display in the Element Properties dialog box:
- Control Type: Grid Column. The type of the UI control.
- Data Class: ARTran. The data access class that contains the inspected field.
- Data Field: DiscPct. The field that is represented by the Discount Percent column in the table.
- Business Logic: SOInvoiceEntry. The business logic controller (BLC, also referred to as graph) that provides the logic executed on the Invoices form.
To modify attributes of the DAC field, select Element Properties dialog box. In the Select Customization Project dialog box, specify the project to which you want to add the customization item for the data field and click OK.
in theThe Data Class Editor opens for customization of the DiscPct
field of the
ARTran
data access class.
PXDBDecimal
attribute specifies the range of valid values for the
field. According to the customization task, you have to modify the minimum and maximum
values specified in the attribute. To do this, you have to replace the original attributes
with the custom ones as follows:- In the Customize Attributes box, select Replace Original. The original attributes will be copied to the text area where you enter custom attributes.
- For the
PXDBDecimal
attribute, change the minimum and maximum values, as listed below.[PXDBDecimal(6, MinValue = -30, MaxValue = 25)] [PXUIField(DisplayName = "Discount Percent")] [PXDefault(TypeCode.Decimal, "0.0")]
- Click Save in the Data Class Editor to save the changes.
The system adds the customized data access class to the Data Access list of project items. For more information, see Customized Data Classes.
To test the result of the customization, publish the customization project, open the Invoices form, insert a new document, and add a record to the details table, as shown in the screenshot below. If you try to specify a value in the Discount column greater than 25 percent or less than -30 percent, the system will automatically correct the value to the maximum 25 or minimum -30, respectively.