Skip to content

Table

Purpose

Data table lookup.

Methods

Binding name: p6.table


Method: String[] lookup(String tableId, Map keys, String fieldName)

Performs a lookup on the given data table tableId using the Map of conditions (list of key=value). Only fieldName values will be returned.


Method: Map[] lookup(String tableId, Map keys)

Performs a lookup on the given data table tableId using the Map of conditions (list of key=value). The table records found are returned as an array of Maps of fieldName and values.


Method: void upsertRecords(String tableId, List<Map<String, String>> records)

Upsert the records in the table named tabledId. If a new record has the same values for the primary keys than an existing record, the existing record’s values are updated with the new ones. If not, the new record is added to the table. If the list of records is empty, nothing happens.


Method: Map[] toList(String tableId)

Performs a lookup on the given data table tableId returning all rows and values.


Method: GPathResult toXml(String tableId, String xmlTemplateText)

Performs a lookup on the given data table tableId returning all rows and values expressed as XML. xmlTemplateText is optional. Use this to override the internal XML template used.


Method: org.w3c.dom.Document toDom(String tableId, String xmlTemplateText)

Performs a lookup on the given data table tableId returning all rows and values expressed as a DOM. xmlTemplateText is optional. Use this to override the internal XML template used.

Default table XML structure:

<table>
    <TABLENAME>
        <rows>
            <row id="0">
                <key id="FIELDNAME1">fvalue1</key>
                <key id="FIELDNAME2">fvalue2</key>
            </row>
        </rows>
    </TABLENAME>
</table>

Examples

Accessing data table records:

def records = p6.table.lookup("Customers", [Cust_ERP_Identifier: "MHP"])
println records
Accessing a single field by name from a data table:
if(p6.table.lookup("Customers", [Cust_ERP_Identifier: "MHP"], "Invoice_Aggregation") == ["true"]){
   println "Invoice aggregation is required!"
}