Agile-Developer

Agile Developer

Table fields

Axpert 11

TStructs (Forms)

IViews

Scripts

Axpert Jobs

Axpert Cards

HTML Plug-ins

Users & Roles

Workflow

Axpert API

Application Var/Params

Publish Axpert Apps

Axpert Mobile

Settings

Utilities

Customization

WebServices

Axfast

Table fields

A table-field is a Collection Field Type (CFT). The properties of this field is provided as a JSON string in the Collection Field Descriptor(CFD). This is used to accept field values in a drop-down table in run time. The drop-down table will have columns & rows as described in the descriptor. The CFD value can be set as below :
{
“props”:{
“type“:“table”,
“colcount“:“4”,
“rowcount”:“5”,
"addrow":"t",
"deleterow":"t",
“valueseparator”:“|”,
“rowseparator”:“||”,
},
"columns":{
“col1”:{
“caption”:“Column one”,
"name":"name",
“value”:“v1”,
“source”:“ ”,
“exp”:“expression to calculate & populate”,
“vexp”:“expression to validate”
},
“col2”:{
}
}
}

At run time, the CFT will popup a table in which data can be entered by the user. The data entered by the user will be stored in the field as one string. The individual field values will be separated by the given value separator. The rows will be separated by a given row separator.
The “type” tag in the CFD can be set to table or form. Forms will be shown as name-value pairs.
The source tag may be set with a field name from the tstruct. This field is a drop-down field if the source field is a drop-down field. The drop-down values from the source are used as drop-down values for this field.

Example:
Consider a use-case where the user is entering the marks of a student:

  • Student name – Selection from a drop-down of students from student master.
  • Subject – Drop-down field
  • Mark – Accept
  • Mark details – Table field that pops up a table as below:
Agile developer lowcode Table Fields

The CFD for the above table would be:

{
"props": {
"type": "table",
"colcount": "3",
"rowcount": "1",
"addrow": "t",
"deleterow": "t",
"valueseparator": "|",
"rowseparator": "^"
},
"columns": {
"1": {
"caption": "Name",
"name": "name",
"value": "",
"source": "",
"exp": "",
"vexp": ""
},
"2": {
"caption": "Subject",
"name": "subject",
"value": "",
"source": "",
"exp": "",
"vexp": ""
}
,
"3": {
"caption": "Mark",
"name": "mark",
"value": "",
"source": "",
"exp": "",
"vexp": ""
},
"4": {
"caption": "Mark Details",
"name": "mark details",
"value": "",
"source": "",
"exp": "",
"vexp": ""
}
}
}

If the test type should be a drop-down, follow the steps given below:
1. Create a hidden field before the Mark details field named “HTestTypes” as a drop-down field.
2. Change the col1 definition in the CFD as below:

“col1”:{
“caption”:“Test type”,
“value”:“ ”,
“source”:“HTestTypes”
}

Another way of doing it is to create the HTestTypes field as a text field with an expression that returns the comma-separated string of the test types like Test -1, Test – 2, Term – 1. The comma-separated values will be converted into a drop-down for Col1.

Dynamic table fields

There is a property named Dynamic Source Field (DSF) for table-fields. This provides a drop-down of fields in this tstruct. In run time, the dynamic source field should be populated with the name of a table descriptor. The CFD defined in the selected table descriptor will be used to create the table in run time.
The Table descriptor option is under Utilities in the developer site. This option accepts a name for the descriptor and the collection field descriptor JSON.
In the above example if the subject is science, then a table as below should be displayed.

Agile developer lowcode Dynamic Table

Define the CFD for both tables as two different records in the Table descriptor option. Name the science table as SciDef and the earlier table definition as OthDef.
Create a field named MarksDSF as an expression field with expression iif(subject={Science}, {SciDef}, {OthDef}). Select this field in the Dynamic source field property for mark details table-field.
This is an extremely powerful concept that can be used for cases like EMR, Lab test forms, cost centers, budget apportioning, textile costing forms, and many more.
Consider an example of employee experience, where the employee can be fresher or experienced. Define the employee experience and use the definition in the Definition Source field as shown below.

Agile developer lowcode Dynamic Table

Call a SQL function from table field

In the table field type, we define a table with JSON a static definition or providing a source field. In addition to these definition types, a new method is introduced i.e., calling a SQL function from the table field type.
During the creation of table field type, in the define table section where we provide the static JSON code snippet, we can provide db@sql_function_name. The SQL function will be provided by the solution team based on the requirement.
Agile developer lowcode SQL Function
We can just call a function or pass parameters. The parameters can be the fields defined in the form or Global variables. For example, a field name called empname defined in the form can be passed as a parameter db@myfunction(empname).
Agile developer lowcode SQL Function
Also, a global variable like company or branch code can be passed as a parameter db@myfunction(:m_companycode)
SQL function

HOW TO CONFIGURE A TABLE FIELD?
Open the Db connection and define a function to fetch the table details based on your requirement. For example, providing an option to create columns based on the case. Define this function in the DB with a suitable function name.
Agile developer lowcode Table Field
In the employee form, we call the function along with the parameter as shown.
Agile developer lowcode employee Form

Note: Here pparms is a field of type simple text defined during form creation.
In the run site, open the form and enter the parameter
Agile developer lowcode employee Form
Next, load the table field
Agile developer lowcode employee Form
The columns displayed are based on the parameter definition that is selected.
Agile developer lowcode employee Form

Try Out

In the Employee form created use table field type for the employee experience parameter, and define a table that will include details like Previous Company Name, Experience in years, Current CTC.
Agile developer lowcode Employee CTC