This script allows you to limit which filter operators are available for certain fields. For example, you may not wish the user to select "begins with" or "contains" for a particular field. In that case, create a DataEngine.SetOperatorList script and remove those operators from the list of operators passed to the script.
Parameters
A reference to the Stonefield Query Application object, the name of the field selected in the filter dialog, the data type of the field, and an XML string containing the operators that are available by default based on the data type of the field. The XML has the following format:
<operators>
<operator>operator description</operator>
<operator>operator description</operator>
...
</operators>
For example, for a character field, the following XML string is passed for the fourth parameter:
<operators>
<operator>equals</operator>
<operator>does not equal</operator>
<operator>begins with</operator>
<operator>does not begin with</operator>
<operator>contains</operator>
<operator>does not contain</operator>
<operator>is blank</operator>
<operator>is not blank</operator>
<operator>is known</operator>
<operator>is unknown</operator>
<operator>is greater than</operator>
<operator>is greater than or equal</operator>
<operator>is less than</operator>
<operator>is less than or equal</operator>
<operator>is between</operator>
<operator>is not between</operator>
<operator>is one of</operator>
<operator>is not one of</operator>
</operators>
Return Value
An XML string containing the operators available for the field. You can simply return the passed-in XML string to keep the default list of operators, or remove those operators you don't want available to the user.
Example
This example removes all but the equals and does not equal operators when filtering on Customer.Country.
Visual FoxPro
lparameters toApplication as SQApplication, tcFieldName, tcFieldType, tcOperators
if tcFieldName = 'Customers.Country'
lcOperators = '<operators>' + ;
'<operator>equals</operator>' + ;
'<operator>does not equal</operator>' + ;
'</operators>'
else
lcOperators = tcOperators
endif
return lcOperators
VBScript
function Main(Application, FieldName, FieldType, Operators)
if FieldName = "Customers.Country" then
Main = "<operators>" + _
"<operator>equals</operator>" + _
"<operator>does not equal</operator>" + _
"</operators>"
else
Main = Operators
end if
end function
JavaScript
function Main(Application, FieldName, FieldType, Operators) {
if (FieldName == 'Customers.Country')
{
return '<operators>' +
'<operator>equals</operator>' +
'<operator>does not equal</operator>' +
'</operators>'
}
else
{
return Operators
}
}
C#
Please note that the method in this script must be named DataEngine_SetOperatorList.
public static string DataEngine_SetOperatorList(SFQApplication sfqApplication,
string FieldName, string FieldType, string Operators) {
if (FieldName == "Customers.Country")
{
return "<operators>" +
"<operator>equals</operator>" +
"<operator>does not equal</operator>" +
"</operators>"
}
else
{
return Operators
}
}
VB.NET
Please note that the method in this script must be named DataEngine_SetOperatorList.
public shared function DataEngine_SetOperatorList(sfqApplication as SFQApplication,
FieldName as String, FieldType as String, Operators as String) as String
if FieldName = "Customers.Country" then
return "<operators>" +
"<operator>equals</operator>" +
"<operator>does not equal</operator>" +
"</operators>"
else
return Operators
End Function
See also
Scripts© Stonefield Software Inc., 2023 • Updated: 06/06/16
Comment or report problem with topic