-
Notifications
You must be signed in to change notification settings - Fork 37
HOW TO Display documents depending on the current user
Plomino views cannot display user-dependent (or current date-dependent) documents. A search mechanism can.
Plomino views use an index to get the list of their documents and their column values.
This index is refreshed only when a document is saved, so it is not possible to have a view's selection formula able to select documents using the current user name.
To do that, we need to use a search page.
Let's assume we have:
- a form named 'frmPurchase' containing a Name field named 'employee_manager',
- a view named 'allPurchaseRequest' listing all the purchases requests.
You want to allow any manager to see all the purchase requests he is responsible for (and not the ones from the other managers).
To do that, add the employee_manager to the index (go to field, Edit, and check Add to index).
Then create a new form named 'frmSearchRequests':
- add a Name field named employee_manager,
- go to Parameters, check "Search form", and enter "allPurchaseRequest" in "Search view".
So for now, a manager can open this search form, pick his name and he will get its requests.
But, you may get this result page directly using the following link:
http://yourserver/yoursite/yourdb/frmSearchRequests/searchDocuments?employee_manager=Eric
Such a link can be computed into a Redirect action with the following formula:
db = plominoDocument.getParentDatabase()
current_user_id = db.getCurrentUser().id
return db.absolute_url()+"/frmSearchRequests/searchDocuments?employee_manager="+current_user_id