plomino / Plomino

Powerful and flexible web-based application builder
33 stars 37 forks source link

max date #802

Closed ermancio closed 7 years ago

ermancio commented 7 years ago

Hi all! I have 5 date fields (D1-D5) in a form and I need to show in a column (in my view) only the max date. In my column formula I set

datelist = [ plominoDocument.getItem('D1'), plominoDocument.getItem('D2'), plominoDocument.getItem('D3'), plominoDocument.getItem('D4'), plominoDocument.getItem('D5'), ] z = max(datelist) return z

but if one of the dates is null, It doesn't work. At the same time if I consider plominoDocument.getRenderedItem('Di'), it doesn't work because the formula shows the max day and not the max date. Any hint?

Thanks in advance

Luca

ermancio commented 7 years ago

I solved it in this way:

datelist = [] if(plominoDocument.getItem('D1')is not None and len(str(plominoDocument.getItem('D1'))) >3): datelist.append(plominoDocument.getItem('D1')) if(plominoDocument.getItem('D2')is not None and len(str(plominoDocument.getItem('D2'))) >3): datelist.append(plominoDocument.getItem('D2')) if(plominoDocument.getItem('D3') is not None and len(str(plominoDocument.getItem('D3'))) >3): datelist.append(plominoDocument.getItem('D3')) if( plominoDocument.getItem('D4')is not None and len(str(plominoDocument.getItem('D4'))) >3): datelist.append(plominoDocument.getItem('D4'))
if(plominoDocument.getItem('D5')is not None and len(str(plominoDocument.getItem('D5'))) >3): datelist.append(plominoDocument.getItem('D5'))

z = max(datelist)

return DateTime.strftime(z,'%d-%m-%Y')

djay commented 7 years ago

Its not a plomino issue but datelist = max( [d for d in datelist if d])