Views
Purpose¶
Call and list views.
Methods¶
Binding name: p6.view
listAll¶
Returns all view names.
Syntax
List<String> p6.view.listAll()
Note
If the item is related to an application, the name will be appkey.name
Example
p6.view.listAll().each() {
p6.log.debug it
}
list¶
Returns all the view names of an application.
Syntax
List<String> p6.view.list([String appKey])
Tip
Specify an empty appKey to return the unpackaged entries.
Examples
Packaged
// List all views belonging to the O2C application
p6.view.list('O2C').each {
p6.log.debug 'O2C view: ' + it
}
Unpackaged
p6.view.list().each {
p6.log.debug 'Unpackaged view: ' + it
}
get¶
Returns the xml definition of a view.
Syntax
String p6.view.get(String viewName [, String appKey])
Example
// Retrieve the invoice view definition for inspection
def viewXml = p6.view.get('InvoiceView', 'O2C')
p6.log.debug 'View XML length: ' + viewXml.length()
update¶
Update the xml definition of a view.
Syntax
void p6.view.update(String viewName [, String appKey], String viewXml)
Example
// Update the invoice view to change the default sort column
def viewXml = p6.view.get('InvoiceView', 'O2C')
def updatedXml = viewXml.replaceAll('sortColumn="Date"', 'sortColumn="Amount"')
p6.view.update('InvoiceView', 'O2C', updatedXml)
updateIndexes¶
Start the indexation job for the view. A P6Exception is thrown if the job is already running for this view.
Syntax
String p6.view.updateIndexes(String viewName [, String appKey])
Note
The views are cached in the Transaction service and cleared after restarting. To restart the platform6.views and platform6.transactions services take a look to the Service DSL
Examples
Packaged
// Re-index the O2C invoice view after bulk import
def jobId = p6.view.updateIndexes('InvoiceView', 'O2C')
p6.log.info 'Reindex job started: ' + jobId
Unpackaged
p6.view.updateIndexes('TransactionView')