Re: HELP: Filter Function
Rofl
This is all the code and if you read the comments contained therein, it explains at exactly what point the dates are "deregionalised" into miltary dates:
Code:
Procedure SetFilters
String sReportId
String[] sClientIDs
String[] sTripTmpStartDates
// Dates are turned into military dates when DateToString or AddFilter manages dates,
// so add more variables here and store the dates after WebGet. This fixes
// the problem and keeps them to whatever the regional settings are.
// Note to self - find out which one is the culprit ...
String sFromDate sToDate
Get psReportId to sReportId
WebGet psValue of oFromClientID to sClientIDs[0]
WebGet psValue of oToClientID to sClientIDs[1]
If (sClientIDs[0] <> 0) Begin
Send AddFilter sReportId "{Client.ID}" C_drGreaterThanOrEqual sClientIDs[0]
End
If (sClientIDs[1] <> 0) Begin
Send AddFilter sReportId "{Client.ID}" C_drLessThanOrEqual sClientIDs[1]
End
WebGet psValue of oFromTripTmpStartDate to sTripTmpStartDates[0]
WebGet psValue of oToTripTmpStartDate to sTripTmpStartDates[1]
// For SetSelectionCriteria - refer above notes.
Move sTripTmpStartDates[0] to sFromDate
Move sTripTmpStartDates[1] to sToDate
If (Not (IsNullDateTime (sTripTmpStartDates[0]))) Begin
Get DateToString of oReport sTripTmpStartDates[0] to sTripTmpStartDates[0]
Send AddFilter sReportId "{TripTmp.StartDate}" C_drGreaterThanOrEqual sTripTmpStartDates[0]
End
If (Not (IsNullDateTime (sTripTmpStartDates[1]))) Begin
Get DateToString of oReport sTripTmpStartDates[1] to sTripTmpStartDates[1]
Send AddFilter sReportId "{TripTmp.StartDate}" C_drLessThanOrEqual sTripTmpStartDates[1]
End
Send SetSelectionCriteria sReportId sClientIDs[0] sClientIDs[1] sFromDate sToDate
End_Procedure
Procedure SetSelectionCriteria String sReportId String sFromId String sToId String sFromDate String sToDate
String sSelectionCriteria
Integer iParameter
// Apply some filtering here if some of the criteria is blank. Work in progress … RW 20190815
Move ("Id: From " + sFromId + " To " + sToId + " - Date: From " + sFromDate + " To " + sTodate) to sSelectionCriteria
Get ParameterIdByName sReportId "SelectionCriteria" to iParameter
If (iParameter <> -1) ;
Set psParameterValue sReportId iParameter to sSelectionCriteria
Else ;
Send UserError "Admin msg: DR Parameter 'SelectionCriteria' does not exist in report." "Information"
End_Procedure
Last edited by Rachael; 16-Aug-2019 at 03:26 PM.
Regards,
Rachael Warlond
1) When programming, never reinvent the wheel.
2) If it works, leave well enough alone.