Hello Domino programmers!
I work on a lotus database + xpages and i ran into a following problem:
I have Authors and Readers fields on document and both can contain users and groups.
Both fields are set on XPage using NamePicker control.
When document is saved i would like to hide an "Edit" button when user doesn't have rights to do so.
Is there a way to just check on document, datasource or context - if current user is document author? Or i have to check it all way long, comparing Authors fields - multiple usernames and groups with current username?
Any help will be appreciated.
You can use the Java method NotesContext.isDocEditable(document) to check if user can edit the document.
In SSJS you can do this:
var ctx = com.ibm.domino.xsp.module.nsf.NotesContext.getCurrent();
return ctx.isDocEditable(doc);
This method is also available as an XSnippet.
Related
I am sending out an HTML email to our users every week in which I want to include links to certain documents and then a link to the overall database. The database is an Xpage db.
On my docs I have a field only visible to me in which I compute the link I need. The format is as follows:
notes://servername/__.nsf/0/?OpenDocument
What I want is the URL to open not just a specific document, but the Xpages app in general. Everything I try opens up the all documents view.
notes://servername/__.nsf/
If I put this in the address bar, it works fine. If I put it in a link, it goes to the all documents view.
Any help would be greatly appreciated.
You could try formatting it as: notes://servername/__.nsf/nameOfXpageYouWantToOpenTo.xsp?OpenXPage
Have you set the launch properties for the database? You can specify a designated XPage in there too.
The format you are looking for is:
notes://servername/yourdb.nsf/someview/unid?OpenDocument
in the "someview" view you add a form formula to point to an empty form that has the property set "open XPage instead" - careful there are 2 of them: for web and client.
If you don't use native forms and the Xpage is always the same, then you can skip the step with the form formula and the extra form and edit the properties of the existing form.
Paul's solution should work too.
Use this code syntax to open any XPage in the Notes client:
#URLOpen("notes://Host/Path/Database.nsf/XPageName.xsp?OpenXPage")
Additional details:
And use the following to open a specific document in the XPage where unid is the unique document identifier for the document:
#URLOpen("notes://Host/Path/Database.nsf/XPageName.xsp?documentId=unid&action=openDocument")
I am developing a database on Lotus Designer 8.5 environment with LotusScript and LotusFormula.
Is there any possibilities on get a list of recently opened documents (for example last five) in a Lotus Notes database ? My purpose is to provide an embedded view showing the recent documents opened by current user on the current database, which will act like some kind of history view.
Please advise
Use a folder categorized by username. Add the current document in PostOpen event to folder with document.PutInFolder(folderName) and remove the oldest document from folder with document.RemoveFromFolder(folderName)
This way you don't need to edit the documents and can show the last visited documents for a user in an embedded view.
As an alternative you can use user specific folders with option "Shared, private on first use".
I have that functionality in one of my databases.
I just added some code in the QueryOpen event of the form to store the UNID of the document in a profile document linked to the specific user. The values are stored in a multi value field, and my code removes the oldest entry when the number of entries I want to store is exceeded.
The user can actually set that number themselves in teh applications settings, 5 is default but they can make it more or less.
I built a class for this, makes it very easy to modify later, and to implement it in different forms, for different document types.
I then built a method to expose the last documents to the user, using a dropdown box as you can see below. Since you only wwant/need the five (or perhas ten) last documents, no need to use a view.
I'd like to add a list of strings to a Dialog list with an Java agent. Item's value changes but it doesn't show the values on form.
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db=session.getCurrentDatabase();
Form form = db.getForm("UOs_AD");
Document document = agentContext.getDocumentContext();
Item item = document.getFirstItem("UO_AD");
Vector v = new Vector();
v.addElement("Bicycle");
v.addElement("Train");
v.addElement("Foot");
Item textListItem = document.replaceItemValue("UO_AD", null);
textListItem.setValues(v);
textListItem.setSummary(true);
document.save(true, true);
I'm not sure that I understand your question. Are you trying to update the Form so that "Bicycle", "Train" and "Foot" will be choices in the dialog list whenever someone creates or edits a document? Or are you trying to update a specific document so that these three values are selected for the field value? Your code appears to be updating the Document.
If you are just trying to get those three values to appear as selected, then make sure that your field has the "Allow values not in list" property selected in Domino Designer. Also, make sure that the "Allow multiple values" property is selected.
replaceItemValue() only replaces the value of a field in the current document (which you got via agentContext.getDocumentContext()) and not the choices that, for example, a Combobox tied to that field offers the user.
If the choices a Combobox offers are static you need to use Domino Designer to open the form the document is based on and change the values offered for the choices in that field. If you want to do that programmatically, you would have to work with DXL.
OK, so based on your latest feedback, your question really should have been:
How can I display the result of an LDAP query (in my case a list of OUs), done with some Java code, in a IBM Notes Dialog List?
You are out of luck with "classic" Domino Designer. A classic notes form only offers you (either via the Designer, but also via DXL) the following options for a dialog list:
Enter choices (one per line): Type a list of choices in the edit box.
Use formula for choices: Type a Lotus Notes formula in the formula window to generate a list of choices.
Use Address dialog for choices: This option displays the Names dialog box so users can select names from a Personal Address Book or Domino Directory.
Use Access Control list for choices: This option brings up a list of people, servers, groups, and roles in the access control list for the database
Use View dialog for choices: This option brings up a dialog box containing entries from a column in a view
So no way of adding the output of some Java code to the Dialog List.
What you can do is:
Use XPages. With XPages, you can have Java code to fill any kind of List, Dialog Box, ...
Use your Java code in a scheduled Notes Agent to "sync" the LDAP entries into the Notes database by creating notes documents, eg. "OU" which represent the LDAP entries. Using a View, you could then use the "Use View dialog for choices" option of the Dialog List to display them to the user.
Use TDI (entitlement for this comes with Domino) to sync the LDAP entries into the Notes database by creating notes documents, eg. "OU" which represent the LDAP entries. Using a View, you could then use the "Use View dialog for choices" option of the Dialog List to display them to the user.
Use your Java code in a scheduled Notes Agent to update a field inside a profile document with the list of "OUs". Then use a #-formula to display the values in the Dialog List.
Solution (2), (3) and (4) have the disadvantage of not displaying "realtime" info of the LDAP directory.
I hope I understood your problem correctly. If so, please edit content and title of your question acccordingly.
I have an embedded View within my form which has a bunch of agents in the embedded view.
However when i select rows(documents) in the embedded view and run the agent (eg "Do a multi profile update") it does work but it does not make any changes to the documents selected. Like the prompt in the lotus script agents does work and pop up but no updates are made.
When ran externally from the view it works fine so for some reason it does not work from an embedded view is what i feel.
The agent within the view is an Action which uses a formula language code #Command([RunAgent];"updatePeople")
were the updatePeople is a lotus script agent.
any ideas or suggestions guys?
I think you have to access the selected documents using an action in the embedded view with the LotusScript logic inside the acrtion instead of calling agents. You can find a complete answer here (with full explanation and code sample):
Domino Designer: Access selected rows from embedded view
I am not sure if this IBM TechNote explains exactly the same issue, but it seems very similar:
How to get a handle on selected documents in an embedded view when using LotusScript
Does the ID have the correct ACL settings for the agent to run?
Does the ID have the ability to edit documents?
Does the Agent have the proper save statements in the code?
The example code in the above link is doing a full db search of unprocessed documents. I would suggest using the ViewEntry document collection. This will allow the agent to run faster since the view could be customized.
Another way to go if you are having issues with processing is to set up a flag field that is updated with the save of your document. The flag field could be used in your view selection field to have the documents fall out of the view if that is desired.
Very new to Lotus designer.
I am trying to create a simple form with a field which is updated from time with additional information. I want the admin user to be able to update this information on the same form interface as the user viewing the information.
It appears I do not really understand how to get the form to display information entered into it previously.
I did Ctrl+shift view of the database and saw all the previous entries but I can not seem to get the form to display these information as well as allow me to append to them.
Kindly help.
Thanks.
Have a look at the online Domino Designer help - for instance the sections on designing forms:
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.designer.domino.main.doc/H_ABOUT__FORMS.html
A form is used to create a new document or to edit an existing document. Since you say that you can see the previous entries, you must be creating a new document for each entry.
If you want to see and modify the contents of an existing document, you have to navigate to the document and open it for edit.
If you want the user to see a list of all the previous documents while he is creating a new one, you can add an embedded view to the form and use that to display data from the previous documents.
If you want all the information to be in a single document, then you need to stop creating new documents and just select the exiting document, open it for edit, make your changes, and re-save the document.