isAuthors and isReaders don't work

hi all: i have a form, including two Author Fields, a Reader Field and some other fields.

if i open the document and input A into an author field, B into a reader field, and [Managers] role into an author field (A and B’s access in ACL is Author), then save it. the authentication works well, only A and managers can read and edit it, and B can read it.

but when i use lotusscript to create document automatically.

my code is:

Set doc_profile = New NotesDocument(db)

doc_profile.form = “profile”

Call doc_profile.AppendItemValue(“emp_name”,employee)

Call doc_profile.AppendItemValue(“emp_fullname”,emp_full)

Set item = doc_profile.ReplaceItemValue(“Authors”, A)

item.IsNames = True

item.isAuthors = True

Set item = doc_profile.ReplaceItemValue(“Readers”,B)

item.IsNames = True

item.isReaders = True

Set item = doc_profile.ReplaceItemValue(“Readers_group”,“[Managers]”)

item.IsNames = True

item.isAuthors = True

Call doc_profile.ComputeWithForm(False,False)

Call doc_profile.Save(True,True)


then isReaders and isAuthors can’t work, A and B can’t see the document in the view, but the managers can open and edit document.

and when manager open it, change the mode to edit, and save the document without changes, then all fields works well too.

the name A and B’s format likes:

  Michael zhan/10091372/GCR/NONEKC

why this happened? anyone can give some helps? thanks in advance!

Subject: isAuthors and isReaders don’t work

Try the following :

Set doc_profile = New NotesDocument(db)

doc_profile.form = "profile"

Call doc_profile.AppendItemValue("emp_name",employee)

Call doc_profile.AppendItemValue("emp_fullname",emp_full)



Dim item As NotesItem

If doc_profile.HasItem ( "Authors" ) Then

	Set item = doc_profile.GetFirstItem ( "Authors" )

	item.Remove

	Set item = New NotesItem ( doc_profile , "Authors" , A , AUTHORS )

Else

	Set item = New NotesItem ( doc_profile , "Authors" , A , AUTHORS )

End If



If doc_profile.HasItem ( "Readers" ) Then

	Set item = doc_profile.GetFirstItem ( "Readers" )

	item.Remove

	Set item = New NotesItem ( doc_profile , "Readers" , B , READERS )

Else

	Set item = New NotesItem ( doc_profile , "Readers" , B , READERS )

End If



If doc_profile.HasItem ( "Readers_Group" ) Then

	Set item = doc_profile.GetFirstItem ( "Readers_Group" )

	item.Remove

	Set item = New NotesItem ( doc_profile , "Readers_Group" , "[Managers]" , READERS )

Else

	Set item = New NotesItem ( doc_profile , "Readers_Group" , "[Managers]" , READERS )

End If



Call doc_profile.Save(True,False)

I presume the Readers_Group field should be of type Readers, your original code was setting it to Authors.

cheers!!

Ashish

Subject: RE: isAuthors and isReaders don’t work

hi LoNo: thanks you suggestion, but i try it, i’m afraid that it doesn’t work too:(

Subject: RE: isAuthors and isReaders don’t work

You might want to take a close look at the data, the code seems fine to me.

cheers!!

Ashish

Subject: RE: isAuthors and isReaders don’t work

hi LoNo: thanks you solution! if i use the following cod


Set db = session.CurrentDatabase



Set doc = New NotesDocument(db)

doc.Form = "testForm"



If doc.HasItem ( "testingAuthor" ) Then

	Set item = doc.GetFirstItem ( "testingAuthor" )

	item.Remove

	Set item = New NotesItem ( doc , "Michael Zhan/10091372/GCR/NONEKC" , pname.Canonical , AUTHORS )

Else

	Set item = New NotesItem ( doc , "Michael Zhan/10091372/GCR/NONEKC" , pname.Canonical , AUTHORS )

End If



If doc.HasItem ( "testingReader" ) Then

	Set item = doc.GetFirstItem ( "testingReader" )

	item.Remove

	Set item = New NotesItem ( doc , "testingReader" , "Michael Zhan/10091372/GCR/NONEKC" , READERS )

Else

	Set item = New NotesItem ( doc , "testingReader" , "Michael Zhan/10091372/GCR/NONEKC" , READERS )

End If



If doc.HasItem ( "testingAuthorGroup" ) Then

	Set item = doc.GetFirstItem ( "testingAuthorGroup" )

	item.Remove

	Set item = New NotesItem ( doc , "testingAuthorGroup" , "Michael Zhan/10091372/GCR/NONEKC" , AUTHORS )

Else

	Set item = New NotesItem ( doc , "testingAuthorGroup" , "Michael Zhan/10091372/GCR/NONEKC" , AUTHORS )

End If

it din’t work well.

but when i change the name “Michael Zhan/10091372/GCR/NONEKC” to “CN=Michael Zhan/OU=10091372/OU=GCR/O=NONEKC”, it work perfectly.

however i don’t know the different between them? could u give me some advance ideas? thanks

Subject: RE: isAuthors and isReaders don’t work

You can use canonical or flat names in Reader/Author Names fields, but not Abbreviated names. When a user looks at the document, they’ll see canonical names in an abbreviated format, which can trick you into thinking it’s stored that way, but it’s not.

flat: Raphael Savir

abbreviated: Raphael Savir/LSDevelopment

canonical: CN=Raphael Savir/O=LSDevelopment

Although convenient, flat names can potentially cause problems if your company merges multiple hierarchies, so it’s safest to use canonical names.

regards,

raphael

Subject: RE: isAuthors and isReaders don’t work

I am not sure what you are doing here :If doc.HasItem ( “testingAuthor” ) Then

Set item = doc.GetFirstItem ( “testingAuthor” )

item.Remove

Set item = New NotesItem ( doc , “Michael Zhan/10091372/GCR/NONEKC” , pname.Canonical , AUTHORS )

Else

Set item = New NotesItem ( doc , “Michael Zhan/10091372/GCR/NONEKC” , pname.Canonical , AUTHORS )

End If

If you check the Designer Help on NotesItem class, the second parameter should be the field name and NOT the value.

Michael Zhan/10091372/GCR/NONEKC = Abbreviated Name Format

CN=Michael Zhan/OU=10091372/OU=GCR/O=NONEKC = Canocalized Name Format.

Its best to store the Canonicalized name format in Authors or Readers field.

cheers!!

Ashish

Subject: RE: isAuthors and isReaders don’t work

You should ALWAYS use canonical format to store names, whether in Names, Readers or Authors fields.

When using @Formulas, you will often get away with using abbreviated forms for names, but hardly ever in LotusScript.

Subject: isAuthors and isReaders don’t work

Is ComputeWithForm required?Probably the field formulas in authors and readers fields have taken over.

cheers!!

Ashish

Subject: RE: isAuthors and isReaders don’t work

i remove the computewithform, it didn’t work too:(