Infotable filter AND/OR
Hi,
I am using the infotable filter functions, when I use single filter it works but when I try to nest AND/OR it doesn't work. I have Activity area, start time, end time and shift name as inputs. I wanted to nest like
(Activity area or (Start time and End time and Shift Name))
I have gone through the examples given in help by ptc but when I try it, it doesnt execute the way I want. It throws error like must bind data shape but I have already binded a datashape.
Please help me with where I am going wrong.
//call close session
//me.getcloseSession();
var headers = { "Content-Type": "application/json"};
var url = "http://"+ me.host + ":" + me.port + "/api/shifts/"+parameterID;
var params = {
proxyScheme: undefined /* STRING */,
headers: headers /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN */,
workstation: undefined /* STRING */,
useProxy: undefined /* BOOLEAN */,
withCookies: undefined /* BOOLEAN */,
proxyHost: undefined /* STRING */,
url: url /* STRING */,
timeout: 15 /* NUMBER */,
proxyPort: undefined /* INTEGER */,
password: undefined /* STRING */,
domain: undefined /* STRING */,
username: undefined /* STRING */
};
// result: JSON
try {
var json = Resources["ContentLoaderFunctions"].GetJSON(params);
var param1s = {
infoTableName : "InfoTable",
dataShapeName : "Ferrara_Shiftnfo_DS"
};
var newInfo = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(param1s);
var tStartTime;
var tEndTime;
for(var i=0; i<json.Items.length; i++)
{
if (json.Items[i].Shift.StartTime.length > 20)
{
tStartTime = parseDate(json.Items[i].Shift.StartTime.replace("T", " "), "yyyy-MM-dd HH:mm:ss.SSS");
}
else
{
tStartTime = parseDate(json.Items[i].Shift.StartTime.replace("T", " "), "yyyy-MM-dd HH:mm:ss");
}
if (json.Items[i].EndTime.length > 20)
{
tEndTime = parseDate(json.Items[i].EndTime.replace("T", " "), "yyyy-MM-dd HH:mm:ss.SSS");
}
else
{
tEndTime = parseDate(json.Items[i].EndTime.replace("T", " "), "yyyy-MM-dd HH:mm:ss");
}
//
if (json.Items[i].Shift.Name != null &&
json.Items[i].Shift.Name != '' && json.Items[i].Shift.Name != ' ' && json.Items[i].Shift.Name.length != 1)
{
// if (json.Items[i].ActivityAreaName == activityName)
{
newInfo.AddRow({parameterSet:json.Items[i].Id,
activityArea:json.Items[i].ActivityAreaName,
WorkCellConfigId: json.Items[i].WorkCellConfigId,
ActivityAreaId: json.Items[i].ActivityAreaId,
shiftName:json.Items[i].Shift.Name,
startTime:tStartTime,
endTime:tEndTime,
State: json.Items[i].State,
Number: json.Items[i].Shift.Number
});
}
}
// }
}
result1 = newInfo;
var query = {
"filters": {
"type": "OR",
"filters": [
{
"type": "AND",
"filters": [
{
"type": "EQ",
"fieldName": "startTime",
"value": startTime
},
{
"type": "EQ",
"fieldName": "endTime",
"value": endTime
},
{
"type": "EQ",
"fieldName": "shiftName",
"value": shiftName
}
]
},
{
"type": "EQ",
"fieldName": "activityArea",
"value": activityName
},
]
}
};
var params2 = {
t: result1/* INFOTABLE */,
query: query /* QUERY */
};
var result2 = Resources["InfoTableFunctions"].Query(params2);
var params4 = {
t: result2/* INFOTABLE */,
query: sort /* QUERY */
};
// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Query(params4);
}
catch(err)
{
me.getCloseSession();
}
Thanks in advance.

