NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: aren1968 on December 05, 2024, 01:49:14 AM
-
I would like to filter a browse with a timestampfield declared as a real.
Rei:Timestamp Real
The filter is : 'p_web.UnixToClarionDate(Rei:Timestamp/1000)=' & Today()
Debugview shows: Filter: (p_web.UnixToClarionDate(Rei:Timestamp/1000)=81792) AND (Rei:DeletedTimeStamp = 0 or NULL(Rei:DeletedTimeStamp) = 1)
Any suggestions how I would get this to work?
-
Hi,
What I do with complex filters is place them in the embed 2 - Before Browse Loop ---10a Set Filter. Photo attached. I put them here instead of in the template Filter line if they are complex
The filter is just a string.
When writing complex filters I will often build a string and check the string.
The filter you want is loc:FilterWas - that will hold your new filter.
Here is some example code:
if p_web.GSV('FROM') = 'OWNER'
if p_web.GSV('loc:datepick')> 0 ! we have chosen a date range
if daterange> 0 ! we have chosen a date range
if daterange = 1
filterstring = 'JSRV:TDATE = ' & onedate & ' AND ' & 'UPPER(JSRV:OWNR_GUID) = <39>' & UPPER(p_web.GSV('LOGGED OWNER_GUID')) & '<39>'
loc:FilterWas = filterstring
elsif daterange = 2
filterstring = 'JSRV:TDATE >= ' & dfrom & ' AND JSRV:TDATE <= ' & dto & ' AND ' & 'UPPER(JSRV:OWNR_GUID) = <39>' & UPPER(p_web.GSV('LOGGED OWNER_GUID')) & '<39>'
loc:FilterWas = filterstring
end
end
else ! no date range - standard inquiry - show last 30 days
!loc:FilterWas = 'UPPER(JSRV:OWNR_GUID) = <39>' & UPPER(p_web.GSV('LOGGED OWNER_GUID')) & '<39>' ! go back 30 days on routine request
filterstring = 'UPPER(JSRV:OWNR_GUID) = <39>' & UPPER(p_web.GSV('LOGGED OWNER_GUID')) & '<39>' & ' AND JSRV:TDATE >= ' & today() -30 & ' AND JSRV:TDATE <= ' & today()
loc:FilterWas = filterstring
end
Hope this helps you get squared away.
Ron
-
Thanks for the suggestion.
I put this code in 10a set filter:
! Filter string here
filterstring = 'p_web.UTCDate(Rei:Timestamp)=' & Today()
loc:FilterWas = filterstring
p_web.trace('Before browse filter, string in embed')
p_web.trace(filterstring) *Outputs the string correct*
p_web.trace('Before browse filter, timestamp uformatted')
p_web.trace(Rei:Timestamp) *Outputs a zero: 0 *
Web trace in Inside browse loop, 3 end of loop
p_web.trace('End of loop')
p_web.trace(p_web.UnixToClarionDate(Rei:Timestamp/1000)) *Outputs a clarion date : 81791 *
My problem seems to be that my timestamp field is empty when the filter loads.
-
The key point to understand is that the filter is just a string, which is then passed to the backend.
Since p_web is an object, it has no meaning in a string.
So p_web.UTCDate isn't text that should be in the end filter.
Rei:Timestamp Real
The filter is : 'p_web.UnixToClarionDate(Rei:Timestamp/1000)=' & Today()
I would turn this around;
'Rei:Timestamp >= ' & p_web.ClarionToUnixDate(today(),0) * 1000 & ' AND Rei:Timestamp <= ' & (p_web.ClarionToUnixDate(today()+1,0) * 1000 ) - 1