I posted this as a reply to a question last year but I still find people asking the same or a similar question every now and then, therefore, I thought I should post it on the blog so that I don't have to search it everytime some one asks a similar question.
Problem: Displaying library items for a specific time period.
Scenario: Display new items in a library for 7 days. The items should disappear from the library automatically after 7 days.
There can be several ways to do this. One way of accomplishing this is as
follows:
1. Add a new column in your library and name it as "HiddenDate".
2. Keep it invisible by clearing the "Add to default view" check box shown
at the bottom of the page.
3. Select "Date and Time" as the type.
4. Date and Time format = Date only
5. Default value = calculated value.
6. In the calculated value, enter "=Today+7"
7. Click OK to save the changes.
8. In the view where you want to see the changes, add a filter. For example,
you can add a filter in the "All Documents" view.
9. In filter section, select "Show items only when the followint is true:".
10. In the columns drop down, select "HiddenDate"
11. In the filter options (second drop down), select "is greater than or
equal to"
12. In the third text box, enter "[Today]".
13. Click OK to save changes.
Now, every time a document is added to the library, it will remain visible
for 7 days and will disappear automatically after 7 days.
You may notice that a form is shown to the user when he adds a new document.
HiddenDate field appears on this form. Because this is an optional field
therefore user can leave it as it is and click the OK button to save the
document but just imagine what will happen if the user changes the date in
this form. Your filter will not work! Therefore, it is important to hide
this field from the user. One way is to customize the document library
template in SharePoint and add the "HiddenDate" field in the template. This
way, hiddendate field will be available in all libraries created using the
new template and user will not be shown this field when he saves the
document. To see how to add a field in the template, see the following post:
/ssa/archive/2006/05/23/7487.aspx
Problem: Displaying library items for a specific time period.
Scenario: Display new items in a library for 7 days. The items should disappear from the library automatically after 7 days.
Solution: |
follows:
1. Add a new column in your library and name it as "HiddenDate".
2. Keep it invisible by clearing the "Add to default view" check box shown
at the bottom of the page.
3. Select "Date and Time" as the type.
4. Date and Time format = Date only
5. Default value = calculated value.
6. In the calculated value, enter "=Today+7"
7. Click OK to save the changes.
8. In the view where you want to see the changes, add a filter. For example,
you can add a filter in the "All Documents" view.
9. In filter section, select "Show items only when the followint is true:".
10. In the columns drop down, select "HiddenDate"
11. In the filter options (second drop down), select "is greater than or
equal to"
12. In the third text box, enter "[Today]".
13. Click OK to save changes.
Now, every time a document is added to the library, it will remain visible
for 7 days and will disappear automatically after 7 days.
You may notice that a form is shown to the user when he adds a new document.
HiddenDate field appears on this form. Because this is an optional field
therefore user can leave it as it is and click the OK button to save the
document but just imagine what will happen if the user changes the date in
this form. Your filter will not work! Therefore, it is important to hide
this field from the user. One way is to customize the document library
template in SharePoint and add the "HiddenDate" field in the template. This
way, hiddendate field will be available in all libraries created using the
new template and user will not be shown this field when he saves the
document. To see how to add a field in the template, see the following post:
/ssa/archive/2006/05/23/7487.aspx
No comments:
Post a Comment