Clear web session

Hi,

I have a notes database which is used as web application. Was wondering how to achive clearing or refreshing web session. Suppose I edit document and make changes then on save and close or unload formula how to refresh session without causing user to re-login.

Subject: Clear web session

I’m not quite sure of what your concept of “clearing the web session is”. Are you trying to make sure, that a newly created documents appears in a view?

Subject: RE: Clear web session

No the newly created documents are working fine. But when I edit document and close it after saving other user has to wait for sometime then he is able to access the document. Guess due to locking. Or if user re-logins in then he his able to edit. understod what I’m trying to do

Subject: RE: Clear web session

Is document locking used, or why do you suspect that there would be any “locking”?

Also what type of access are you referring to? Is the other user unable to see the document, unable to open it or unable to edit it? What happens instead of what you expect? Any messages?

Subject: RE: Clear web session

Document locking is not used, but there’s a hidden field which is set a flag not allowing users to edit document if already a user has opened document for editing. If user A is making changes currently, the flag is set true and user B gets msg cannot edit. Once user A saves or unloads the page, the user B should be able to edit document. But same msg appears cannot edit. I even set breakpoint to check if flag becomes false after user saves and closes document. The flag is set false. User B can edit document again only after re-login or waits for sometime nearly 10 mins. I tried using LSsession.clearstatus but even that didnt work.

Hope it is clear now.

Subject: RE: Clear web session

So, now that we finally know, that you have some home-grown locking code in place, it would be helpful to see what your WQO agent does.

If user B gets to see the message that the document is locked after he’d tried to open it before, the issue could be, that the browser works with a cached copy of the document. If this is not the case, one probable cause would be that your WQO code works on a view, that is not up to date. But without knowing the actual code, this remains speculation.

Subject: RE: Clear web session

Hi Harkpabst,

I’m not sure if I can post in the code since its huge. But what happens in code I can describe in detail say something like algorithm so it will give you an idea.

WQO:

15 fields are being set to blank.

Edit event:

Call agent which in turn sets locked field to true. Here it does not use any view just below lines

Set db = session.CurrentDatabase

Set doc = session.DocumentContext

Set doc2 = db.GetDocumentByUNID(doc.UniversalID) 

            If locked = true & username = loginID then

                    Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?EditDocument]")

            else

                    Msg (In Edit mode)

            end if

OnUnload event:

if (isEditMode && isLocked) {

location.href = revisedURL + “(WebUnlock)?openagent”;

}

WebUnlock agent:

Here it checks if doc is locked and if same username then set lock field to false and save document.

Since this didnt work I placed code to call agent in WQS too.

From above I think it could be related to cache document. It would be great if you could suggest something about it plus even for view update. Most of views I have set property as autoupdate but still no change.

Hope this information helps you to give me solution

Subject: RE: Clear web session

Hey any updates anyone

Subject: RE: Clear web session

Your code sample is still missing some of the important bits, I’m afraid.

Where exactly is your “edit event” code located? You are using .DocumentContext, so I would assume, that it is in the WQO agent as well, because .DocumentContext refers to the current document in WQO and WQS agents only. But the next lines don’t really seem to fit.

Why are you using the doc2 object at all? doc either is the current document already (WQO/WQS agent), or if it’s not, then doc.UniversalID will not point to that document anyway. If this code resides in an agent, that is called directly via ?OpenAgent, then .DocumentContext points to new temporary document, that’s only intended to retrieve CGI variables.

Also, you cannot redirect in a WQO agent, so what exactly would the print statement do? Where and how is your variable “locked” filled?

If I were in your position, I would probably rather use separate lock documents instead of trying to store the locked status in the document itself.

Subject: RE: Clear web session

Hi,

Here is the entire code for locking the document.

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim doc2 As NotesDocument

Dim username As String

Dim curruser As Variant

Dim wholocked As String 

On Error Goto whoops 

Set db = session.CurrentDatabase

Set doc = session.DocumentContext

curruser = Evaluate({ @Name([CN];@UserName) }, doc)

username = curruser(0) 

'following step is done because the user could have opened the doc and only hit the edit button a few minutes later

'by which time another user could have opened and edited/locked the same doc

Set doc2 = db.GetDocumentByUNID(doc.UniversalID) 

If Not doc2 Is Nothing Then

	If doc2.HasItem( "isLocked" ) Then

		If doc2.isLocked(0) = "Locked" Then

			If doc2.HasItem( "WhoLocked") Then

				wholocked = doc2.WhoLocked(0)

				If wholocked = username Then

'open in edit mode

'the person who locked it is trying to edit it, so allow this

					Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?EditDocument]")

				Else

'open in read mode

'the person other than the person who locked it is trying to edit it, so do not allow this

					Call LockedMessage(wholocked)

					Goto cleanexit

					Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?OpenDocument]")

				End If

			Else

'open in read mode

'system problem as there is no person assigned to the WhoLocked field, so do not allow this

				Call LockedMessage(wholocked)

				Goto cleanexit

				Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?OpenDocument]")

			End If

		Else

'set locked

'not locked so set to locked

			doc2.isLocked = "Locked"

			doc2.WhoLocked = username

			Call doc2.Save(True, False)

			Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?EditDocument]")

		End If

	Else

'set locked

'not locked so set to locked

		doc2.isLocked = "Locked"

		doc2.WhoLocked = username

		Call doc2.Save(True, False)

		Print("[" + db.filepath+"/unid/"+doc2.UniversalID+"?EditDocument]")

	End If 

End If 

cleanexit:

Exit Sub 

Whoops:

Dim strErrMsg

Dim strMsg

strMsg = Err & " " & Error$ & " Line " & Erl & " in " & Lsi_info(2)

strErrMsg = "<HR>Error #" & Err & Chr$(10) & Error$ & Chr$(10) & "Line #" & Erl & | in sub/function: "| & Lsi_info(2) & |"|

strErrMsg = strErrMsg + |<br>Please report this to <a href="mailto:x09731@arrowpointcap.com?Subject=Doc Locking Problem?Body=| + strMsg + |">Your Name"</a><HR>|

Print strErrMsg 

Exit Sub

End Sub

The edit event is in a subform and on clicking the edit button this agent is triggered thru formula @command([toolsrunmacro]; “weblock”)

If its possible to clear session pls do let me know or do I have to change my approach.

Subject: RE: Clear web session

Well the problem is with cached document. This is what I did to find out what exactly is the problem. Created a view which will show document status. When I edit a document, the view gets updated with locked status. After I make changes, save and close it, the view is updated with unlocked status. So the coding part seems fine. After I save and close, other user still gets the same message locked by user xxxxx. I assume this is due to document already in memory.

How to make browser fetch documents from database and not cached memory any idea?