I’m trying to write a QueryOpen using LotusScript, but the problem is that I want to access a particular field in the document that we’re querying. (Basically, if the user’s name is included in a certain field, then it will allow them in.)
Is this possible? I don’t see how I can get a hold of that field value until I’m in the document. (For example, Set Source = workspace.CurrentDocument won’t work because we’re not yet in the document.)
Subject: RE: QueryOpen for Document based on doc field?
Yes, Source works. Thank you!
But if the field has multiple values, how do I check whether the userName is one of those values? I realize that I’m getting a String array from the getItemValue method, but I don’t know how to check the array. I’ve tried using the Instr method without providing an index on the field, but this fails. I think that I need an “inArray” method rather than “inStr.”
If Instr( doc.getItemValue(“AdditionalEditors”), session.UserName ) > 0 Then 'FAILS HERE
Subject: RE: QueryOpen for Document based on doc field?
Marc,
Stan is right that is what readers and authors are for, however, I have used what you are doing as well. If the arraygetindex give you some issues, you can always use the .contains of the item as well as in…
Subject: RE: QueryOpen for Document based on doc field?
Yes, I was just about to post a question about ArrayGetIndex when I saw Stan’s response. The Readers field is probably what I should use, although I still have some minor issues (see my response to Stan).
So if I do need to fall back on Script, how do I know what Notes version these methods were introduced with? We still have some users on 4.5.6, and I seem to recall an issue with the “contains” method. I would expect this information to be in the Notes Help documentation, but I’m not seeing it.
Subject: RE: QueryOpen for Document based on doc field?
ArrayGetIndex won’t work on R4 either – you would need to use Instr (or an equality check) in a Forall to check all of the values in the array, or Evaluate({@Contains(FieldName;“} + session.UserName + {”)}, doc}).
Subject: RE: QueryOpen for Document based on doc field?
I’ve searched through the forum many times about this similar situation to learn how to restrict user with Editor access from seeing and editing the documents which other user created besides their name was not appeared in any field from the document.
I may coded it wrong but after many failures, I would need Notes guru expert from the forum to help me looking into the code for me below:
I have a form with authors and readers fields, and enter the value for :
Authors field - Computed When Compose - value is “”
Readers Field - Computed when Compose - value is list string of names and field names, I entered into the Reader field all the names as :
Please advise me how to enter these properly, I guess I didn’t do it correctly here.
If Reader and Author field I would like your guidance again how to enter LS into queryopen event instead of using author and reader fields, which I follow Stan’s instructions from
Maybe I didn’t entered the name properly from the reader field.
should I use fullname or just CN name?
I really like to use the QueryOpen to control users accessing to the document which they are not author, or their names not in a field from the documents.
Please pardon if this message is not clear, but I will continue to search from the forum.
Subject: RE: QueryOpen for Document based on doc field?
Look at ArrayGetIndex in Designer Help. It’s not exactly Instr, but if you know the exact values you’re looking for, it will help. HOWEVER – this is what Readers and Authors fields are for; there’s no need to code events for this sort of thing.
That is, if the Category field is not “Assessments,” then no value (and thus no Reader restrictions, right?). Otherwise, contatenate the listed field values for Readers.
BUT one last detail… Is there a way to add roles to this field?
Subject: RE: QueryOpen for Document based on doc field?
Sure is – a role will work as an allowed value in either a Readers or Authors field. Just one thing, though – if your role is for an “always read” value (like the ol’ [Admin] standby), then it’s better to include the role in an Authors field rather than a Readers field. An Authors field will grant read access without removing access from anyone else. (I prefer to keep the “always read” role in its very own Authors-type field so it stays out of the way of any user activity.)
Subject: RE: QueryOpen for Document based on doc field?
But the role(s) would need to be in a separate Readers field, so we would need one for a list of Names, and another for roles, right? For example, it doesn’t seem to like it when I add [Writers] to a list of names.
EDIT: Oh, wait… The roles just need to be in quotes, then they can be concatenated with the other Names. (Right?)