RAD function: filequeryex

A RAD function that returns the query parameters of a file variable.

Function

filequeryex

Format

filequeryex(file)

Parameters

file is an ITSMA Service Management file variable, which can be either $L.file in RAD or SCFile in JavaScript.

Factors

This function returns an array with the following elements:

  • No.0 is the query string, which supports both ITSMA Service Management queries and ADHOC SQL queries.
  • No.1 is the sort-by fields, separated by a comma. Note that the group-by fields will be merged with a higher priority.
  • No.2 is the sort-by order: 0 is ascending, 1 is descending, and an empty value is NULL.
  • No.3 is the group-by fields, separated by a comma.
  • No.4 is the group order: 0 is ascending, 1 is descending, and an empty value is NULL.

Note To set the sort-by and group-by arrays, use "var sortOrder=[SCFILE_ASC];" instead of "var sortOrder=new Array(SCFILE_ASC);".

Examples

Achoc query example:

var file = new SCFile("probsummary");
var sql = 'select affected.item, number from probsummary where affected.item isin (select logical.name from device where owner=\""Administration\"")';
var success=file.doSelect( sql ) ;
var fields = new Array("affected.item");
var sortOrder=[SCFILE_ASC];
var rc = system.functions.setsort(file,fields,sortOrder);
var q = system.functions.filequeryex(file);
print("rc: " + success + ", q[0]: " + q[0] + ", q[1]:" + q[1] + ", q[2]:" + q[2]+", q[3]:" + q[3] + ", q[4]:" + q[4]);

Non-adhoc query example:

var sql='number#"IM1"';
var f1 = new SCFile("probsummary");
var rc =f1.doSelect(sql);
var fields = new Array("affected.item");
var sortOrder=[SCFILE_ASC];
var rc = system.functions.setsort(f1,fields,sortOrder);
var q = system.functions.filequeryex(f1);
print("rc: " + success + ", q[0]: " + q[0] + ", q[1]:" + q[1] + ", q[2]:" + q[2]+", q[3]:" + q[3] + ", q[4]:" + q[4]);