Skip to content
Developerhome
X3

Add your custom fields and tables

  Less than to read

Add your custom fields

In this example, custom fields are added to the PRECEIPTD table (Receipt lines) to hold information about the carbon footprint of our goods. The created custom fields are the following:

  • A decimal field to hold the actual carbon footprint figure that will be computed by the add-on. Let's call that field XCFTPRINT (Carbon footprint).
  • The unit in which it will be expressed. Let's call that field XCFTUNIT (Carbon footprint unit in CO equivalent, or COe).

This time, when adding the fields, Property names for GraphQL are given to the fields. Then, the fields are added to our add-on package (@onetinyplanet/xeimpact):

After, you can Save and Validate the table.

Bonus

Add the XCFTPRINT and XCFTUNIT fields to the details grid in the PTH1 screen. This allows the update of one of the receipts, so tests become meaningful. This is classic Sage X3 development:

  • Insert the two fields in the PTH1 screen, block 2, in positions 9.1 and 9.2.
  • Validate the PTH1 screen.
  • Validate all or one Receipt entry transaction of your choosing. For example, STD.

In the final add-ons, those carbon footprint values are to be computed. In the image below, you can see a few values entered for the sake of testing the API:

Validate the node bindings

After fields are added, node bindings are required to be validated to generate all the data needed for GraphQL queries.

Go to Development > API > Node bindings. You may select any of the records in there as the current record is not important. Select the Validate button to tell X3 to generate all the required data.

Node bindings and the binding dictionary contain all the details that bind the X3 metadata dictionary with GraphQL nodes and operations.

In this example, Purchase Receipts are to be queried, and the new information should be displayed in the API.

Receipts have a standard node defined through the data models API_PRECEIPT and API_PRECEIPTD. These can be seen in the Data models function. For this example, they don’t need to be modified or viewed because the created custom fields were added to the standard table. However, you can see the bindings those Data models generate in the Node binding function.