Problem with GetDocumentByKey & @Command( [FileOpenDatabase]

Hi Everyone,I have strange problem. It work fine for everyone except with ONE user.

I have functionality when user clicks on one button of the current document, a new document has to open from other database based on unique key. If not found it has to create a new document in other database.

The problem is …for one user it will always opens a new document although there is a document with the key.

I tired with GetDocumentByKey & @Command( [FileOpenDatabase]. Both are not working.

note: user can goto that database and open any document. the problem is when i try to open through code it’s not working.

When I tried by hardcoding all the values, then Getdocumnetby returns nothing where as @Command( [FileOpenDatabase] gives wrong document.

I have this problem only with one user. please help me.

Subject: Check that user’s access level in ACL

Hi San,

If you have problem with one user only, and for others the same code is working properly, THEN the problem must be associated with user’s Effective Access Level in that database ACL.

You said user can goto that database and open any document, can he Edit that document? I guess he is having Reader Access to database. And through code you were trying to open that document in Edit mode.

Also In document there are Readers and Authors fields which refines the database ACL. Also check that fields. I hope this helps you.

Regards,

Omkar Naik

Subject: RE: Check that user’s access level in ACL

Hi Omkar,Thanks for your response.

The User has proper rights. Editor on both database and he can edit all the documents.

The problem is he can’t open the document of another database from one database.

I have hardcoded all the values like server,database,view and key on test button then also no use.

and there are no authors & Readers fileds in the database.

Very strange problem ever I have faced on production.

Regards,

San

Subject: RE: Problem with GetDocumentByKey & @Command( [FileOpenDatabase]

It sounds like the user has re-sorted the view you’re using for lookups, so that the sort order is no longer by whatever key you normally use to find the document. That’s one reason it makes sense to use hidden views for your lookups; then you can open the document by its UNID.

Why use FileOpenDatabase to navigate to a document? Unless you needed to open the view for another reason, that’s a waste of time. Use EditDocument method in LotusScript to open just the document.

Subject: RE: Problem with GetDocumentByKey & @Command( [FileOpenDatabase]

Hi Andre,Thanks for giving valuble input.

I have checked the view’s sorted order. it’s fine. User don’t have option to change it’s order.

As it’s an existing application where everything is written in formula language, We can change now.

But I have tried to open the document using lotus script also…by hardcoding the values, still It didn’t worked.

Subject: RE: Problem with GetDocumentByKey & @Command( [FileOpenDatabase]

You have to show your exact code and say what you mean by “not working.”

Please read this: C R I S P Y document.

  • Andre Guirard, IBM/Lotus Development

Useful blog: Best Practice Makes Perfect

Subject: RE: Problem with GetDocumentByKey & @Command( [FileOpenDatabase]

Hi Andre,

Here is the code:

In formula language:

key:=“7B3DF519027D167F852574E80056F663”;

server := “ABSSSO018”;

path1:=“Dev\apps\regAttach.nsf”;

view := “ComUnID”;

@Do(

@Command([FileOpenDatabase];Server : path1 ; view ; key);

@Command([OpenDocument]);	

@Command([FileOpenDatabase];Server : path1 ; view ; key);

@Command([FileCloseWindow]))

It’s opening a different document to only one user.

In lotus script:

Sub Click(Source As Button)

On Error Goto ProcessError

Dim ws As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument



key="7B3DF519027D167F852574E80056F663"

server = "ABSSSO018"

path1="Dev\\apps\\regAttach.nsf";

Set db = session.GetDatabase(server, path1)

Set view = db.GetView( "ComUnID" )

Set doc = view.GetDocumentByKey(key, True )	



If Not (doc Is Nothing) Then

	Call ws.EditDocument(True, doc)

End If



Exit Sub	

ProcessError:

Msgbox "Error Number: " + Cstr(Err) + " : " + Error$ + " on Line number: " + Cstr(Erl) +" <>Database: "+ db.Title 

End Sub

This gives nothing as it’s not finding any document with the same user.

the above code works fine with all users.

Subject: RE: Problem with GetDocumentByKey & @Command( [FileOpenDatabase]

I’ve looked at your earlier posts and I do not see the answer to this question. If you sit down at this user’s computer, using their ID, and manually open the view, and use the view quick search with the key value you are showing here, can you find the document in the view?

Just because there is not a Readers field in your application, does not mean that there could not be a Readers item in the document. You can create one in the Security tab of the document properties, for any document, regardless of the design of the application.

What is the formula of the sorted view column?

What happens when you run the same script?

If you look at the document’s properties, and on the second tab, find the item that contains the key value, what is the value of that item? What is the datatype of the item and its flags? Compare that to another document in the same view. Are they different in any way?

Subject: RE: Problem with GetDocumentByKey & @Command( [FileOpenDatabase]

Hi Andre,Thanks a lot , My issue has been resolved.

There is a column at the end of the view, which have sorting option which I did n’t observed earlier.

The user has changed sorting order on his workspace, so lookup not working.

Thanks once again.

Regards,

San