You Can View User Feedback To This Tip
Recently I was asked to develop a project management tool. A major part was a view showing project progress, in particular any "late running" projects.
Projects were broken down into milestones (which had target dates), so each project document had the possibility of having many target dates.
My problem was how to spot a late project from many dates, within a view?
Code
I started off with a massive @if statement, comparing dates and complete fields, which caused all sorts of problems + I knew it was extremely inefficient.. I finally came up with the following code:
Dates:=@trim(@text(@if(Complete_0="Yes";"";@if(Complete_1="Yes";"";Date_1):@if(Complete_2=
"Yes";"";Date_2):@if(Complete_3="Yes";"";Date_3):@if(Complete_4="Yes";"";Date_4):@if(Complete
_5="Yes";"";Date_5):@if(Complete_6="Yes";"";Date_6):@if(Complete_7="Yes";"";Date_7)
:@if(Complete_8="Yes"
;"";Date_8):@if(Complete_9="Yes";"";Date_9):@if(Complete_10="Yes";"";Date_10):
@if(
Complete_11="Yes";"";Date_11):@if(Complete_12="Yes";Date_12;"")));
TDay:=@today;
@if(Dates="";0;TDay>@texttotime(Dates);84;83);
The code creates a list of valid dates (Dates), removes the whitespace/blank entries and compares it to todays date. If one or more fail (ie. date is in the past), the down thumb icon is shown.
USER FEEDBACK TO THIS TIP
- This might be a good tip, if we knew the structure before jumping into the code. How many date fields are there, what are their names, or are all dates store in one field... we need to know what the options are before we get thrown into the solution. That was very confusing and to test it on my end, I don't know how many fields to put on the form, named what and what data type they are. Need more details.Ruth Inman