Formatting list data

The data displayed in the transaction list is used in other areas of the list, such as the Information Pane. It is also used in the reports that can be generated from the list contents or exported to Microsoft Excel. The formatting applied to this data will vary, depending on where it is used. For example, when a currency value is displayed in the Information Pane, you may want it to appear with a currency symbol. When that same value is exported to Excel, you may want just the numeric portion without a currency symbol.

To have the Print This List or Send To Excel actions appear in the Action Pane for a list, you must have the FormatField procedure defined first.


The FormatField procedure for the list is used to specify the formatting for fields in the list. This procedure is automatically called as each field is displayed in the Information Pane, used in the reports generated from the list, or exported to Excel. The procedure has the following parameters:

in reference TableRef;
in ColFieldID nFieldID; 
in ColArrayIndex nArrayIndex;
in integer nFormatFor;
out string sValue;
out integer nAlignment;

The table reference parameter provides access the current record in the temporary table used for the list. The field and array index paramters indicate which field is being displayed and may need formatting. The “format for” parameter will be set to one of the following constants, indicating where the field value is to be used:

[spacer]

Constant

Description

LIST_FORMATFOR_EXCEL

The value is being formatted for exporting to Excel.

LIST_FORMATFOR_PREVPANE

The value is being formatted for display in the Information Pane.

LIST_FORMATFOR_REPORT

The value is being formatted for display in the report generated from the list content.


The formatted value is passed back out of the procedure as a string. Consider using the following functions defined for the syListObj form to help with formatting the list data:

 

You will also specify the alignment of the formatted data value. The last parameter of the procedure must be set to one of the following constants to specify the alignment:

[spacer]

Constant

Description

ALIGN_LEFT

Left-aligned

ALIGN_CENTER

Center-aligned

ALIGN_RIGHT

Right-aligned


The following example is the FormatField procedure for the Contact History transaction list defined in the sample integrating application. It formats each of the values that can appear in the list.

in reference TableRef;
in ColFieldID nFieldID; 
in ColArrayIndex nArrayIndex;
in integer nFormatFor;
out string sValue;
out integer nAlignment;

local string s;

{Assume default left alignment}
nAlignment = ALIGN_LEFT;

case nFieldID
	in[resourceid(field 'Customer Number')]
		sValue = List_FormatString('Customer Number' of table(TableRef), nFormatFor) of form syListObj;
	in[resourceid(field 'Customer Name')]
		sValue = List_FormatString('Customer Name' of table(TableRef), nFormatFor) of form syListObj;
	in[resourceid(field 'First Contact Date')]
		sValue = List_FormatDate('First Contact Date' of table(TableRef), nFormatFor) of form syListObj;
	in[resourceid(field 'Last Contact Date')]
		sValue = List_FormatDate('Last Contact Date' of table(TableRef), nFormatFor) of form syListObj;
	in[resourceid(field 'Contact Salesperson ID')]
		sValue = List_FormatString('Contact Salesperson ID' of table(TableRef), nFormatFor) of form syListObj;
	in[resourceid(field 'Contact Salesperson ID 2')]
		sValue = List_FormatString('Contact Salesperson ID 2' of table(TableRef), nFormatFor) of form syListObj;
	in[resourceid(field 'Active')]
		sValue = List_FormatBoolean('Active' of table(TableRef), nFormatFor) of form syListObj;
	else
		s = getmsg(6703); {Unknown [%1]}
		substitute s, str(nFieldID);
		sValue = s;
end case; 


Documentation Feedback