We have recently installed Notes 6 on a test server, clients are still running R5. I have encountered a problem when testing a scheduled agent.
The agent clears and repopulates authors fields on a set of documents. Initially when the agent runs it successfully clears the authors fields on all documents and saves the documents. The agent then crashes with the error “You are not authorised to perform that operation” when it has repopulated the authors fields and attempts to save the first document. If you try to run the agent a second time it crashes with the same error but this time when attempting to access the first document to clear the fields. The document is still visible in the view but cannot be opened. There is a separate authors field on the document which includes the server name. This field is not amended by the agent.
If you add a readers field to all the documents and include a role which is assigned to the server and users in the ACL, then the agent runs without any problems. Is it necessary to include a readers field as well as the authors fields when using Notes 6?
Has anyone encountered this problem before and can anyone explain it?
Subject: Problem populating authors fields on docs with no readers fields
The issue is that when you delete the authors field, your agent no longer has access to the document.
If your agent is signed by your server ID (the same as the one in the separate authors field), you’ll probabbly find it’ll work (provided that the authors field contains the full heirarchical name).
But it’s never a good idea to hard code names of servers in fields.
Instead, try to have another authors field on the document (maybe call it DocAuthors), and put in the role which you can assign to the server and admin users Eg. ‘[DocAuthors]’, and also assign this to the ID which has saved the agent (the signer, or server in your case).
It’s also good practice to include a readers field eg. DocReaders, and put in ‘[DocReaders]’, assigning the role to those that may need it.
This will make sure that the agent and server always has access to the documents, and if they need to process the data, they can. This way you can specify users who will always have access to the documents, and the main authors field (the one you’re updating) will take over when users aren’t assigned the ‘DocAuthors’ or ‘DocReaders’ roles.
Only assign the ‘DocReaders’ role to users who need to always read all data. Only assign ‘DocAuthors’ to users who always need to edit all data (eg. admin, servers, and agents). And for the rest of your users don’t assign either role - this way the authors field will take precedence - if their name is in the field, they’ll be able to read and process the document.
A bit long winded…but let me know if it’s not clear. The above is a ‘best practice’ which will ensure that you never lose control of your data.
Subject: RE: Problem populating authors fields on docs with no readers fields
Thank you for your posting.
The issue is that this agent worked in R5 but fails when Notes 6 is installed on the server unless there is a readers field on the document. Anyone with read access and above in the ACL should at least still be able to read the document when there is no readers field although the contents of the authors fields have been cleared.
Are you aware of any changes in this area when upgrading from R5 to Notes 6?
Subject: RE: Problem populating authors fields on docs with no readers fields
Could you please clarify what you mean.
Why should the authors fields affect users reading the document if there is no readers field on the document and the users concerned (i.e. the server and the id that signed the agent) have manager access to the database in the ACL?
Subject: RE: Problem populating authors fields on docs with no readers fields
How certain are you that there is no Readers field in the document? Notice I say in the document as opposed to on the form, because documents can contain fields that don’t appear on the form – they might be left over from previous versions of the form, or have been inserted by agents or other LotusScript/Java code. Users can also set Readers for a specific document in the document properties dialog.
Subject: Resolved - Problem populating authors fields on docs with no readers fields
Thankyou for your postings but I think I have found what the problem was.
The agent that was repopulating the authors field was setting it to IsNames each time a name was added then saving but not setting IsAuthors until all author names had been added to the field. R5 allowed you to set the Authors field type after the field had been populated and the document saved but Notes 6 does not.
The authors fields already existed on the document as type Authors. The agent was using GetFirstItem and AppendToTextList to repopulate the fields but because Notes recognised it as an authors field and I was populating it with text and then setting it to IsNames and saving the document each time, some new security feature in Notes 6 was immediately locking everyone out of the document regardless of their ACL access because the Authors fields were being populated incorrectly. The message returned by the agent was “You are not authorised to perform that operation”.
If a readers field existed on the document then the ACL access was unaffected.
Also, if ReplaceItemValue was used instead of GetFirstItem then this worked because the agent was not picking up a field that was already an Authors field it was simply replacing a field value.
The solution was to set IsAuthors prior to each save rather than setting IsAuthors at the end once the field had been populated.
Subject: RE: Resolved - Problem populating authors fields on docs with no readers fields
I find it mildly shocking that you apparently have a loop in your code that adds multiple names to one document, saving the document each time. That’s extremely wasteful. Save the document only after you’ve added all the names. For that matter, AppendToTextList is a little inefficient for adding multiple entries. Use an array of names and ReplaceItemValue (of course the array must include the values already in the field that you want to keep).