12-19-2019, 10:12 PM
I got it....The issue was the query operator,
for anyone trying to search records look at query operators in the documentation ..graaah
Heres the code to search records between 2 dates and display it into the datagrid (You will have to adjust to suit your keys)
Important Note: If you just use ">=" and "<=" this will leave out dates between 01 and 09 if you run a query from lets say the 1 december to the 20 december...use "date>=" and "date<="
on mouseUp pButtonNumber
local tInputA, tOutputA, tTableID, tKeys, tCount, tDataA, tRecordID, tFromDate, tToDate,
put text of field "dateFromField" into tToDate
convert tToDate to short date
put text of field "dateToField" into tFromDate
convert tFromDate to short date
put cdb_TableID("logs") into tTableID
put cdb_tableKeys("logs") into tKeys
put "date" into tInputA[tTableID]["query2"]["key"]
put "date<=" into tInputA[tTableID]["query2"]["operator"]
put tFromDate into tInputA[tTableID]["query2"]["value"]
put "date" into tInputA[tTableID]["query1"]["key"]
put "date>=" into tInputA[tTableID]["query1"]["operator"]
put tToDate into tInputA[tTableID]["query1"]["value"]
put cdb_batchQuery(tInputA,"cloud","logicalAND","recordData") into tOutputA
put 0 into tCount
repeat for each key xRecordID in tOutputA[tTableID][1]
add 1 to tCount
put tOutputA[tTableID][1][xRecordID]["cdb"]["cdbRecordID"] into tRecordID
repeat for each item xKeyName in tKeys
put tOutputA[tTableID][1][xRecordID][xKeyName] into tDataA[tCount][xKeyName]
end repeat
end repeat
set the dgData of group "DataGridLogs" to tDataA
set the dghProp["saved data"] of group "DataGridLogs" to tDataA
end mouseUp
for anyone trying to search records look at query operators in the documentation ..graaah
Heres the code to search records between 2 dates and display it into the datagrid (You will have to adjust to suit your keys)
Important Note: If you just use ">=" and "<=" this will leave out dates between 01 and 09 if you run a query from lets say the 1 december to the 20 december...use "date>=" and "date<="
on mouseUp pButtonNumber
local tInputA, tOutputA, tTableID, tKeys, tCount, tDataA, tRecordID, tFromDate, tToDate,
put text of field "dateFromField" into tToDate
convert tToDate to short date
put text of field "dateToField" into tFromDate
convert tFromDate to short date
put cdb_TableID("logs") into tTableID
put cdb_tableKeys("logs") into tKeys
put "date" into tInputA[tTableID]["query2"]["key"]
put "date<=" into tInputA[tTableID]["query2"]["operator"]
put tFromDate into tInputA[tTableID]["query2"]["value"]
put "date" into tInputA[tTableID]["query1"]["key"]
put "date>=" into tInputA[tTableID]["query1"]["operator"]
put tToDate into tInputA[tTableID]["query1"]["value"]
put cdb_batchQuery(tInputA,"cloud","logicalAND","recordData") into tOutputA
put 0 into tCount
repeat for each key xRecordID in tOutputA[tTableID][1]
add 1 to tCount
put tOutputA[tTableID][1][xRecordID]["cdb"]["cdbRecordID"] into tRecordID
repeat for each item xKeyName in tKeys
put tOutputA[tTableID][1][xRecordID][xKeyName] into tDataA[tCount][xKeyName]
end repeat
end repeat
set the dgData of group "DataGridLogs" to tDataA
set the dghProp["saved data"] of group "DataGridLogs" to tDataA
end mouseUp