Refresh/Update on QueryOpen IF user = names field
90 pts.
0
Q:
Refresh/Update on QueryOpen IF user = names field
The documents have complicated security, so I need to check if the user matches either of a few names fields first. If yes I need the documents updated (same as if user clicked and Edit button and saved and refreshed) so that certain fields that are pulling values from a view that draws from a different form, can updated. I need to happen when the user opens the document.
R5.0.13

I've tried source.FieldGetText
Set Nitem = source.GetFirstItem
to get the values to compare then
Source.Editmode = True
Call source.save
Source.Editmode = False
ASKED: Jun 25 2008  7:46 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
190 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
This is a tricky area, the first thing to remember is that you need to compare like with like so convert the current users name into a notesName and read each name from the security fields into notesNames for comparison purposes.

You get the current user from notesSession

dim s as new notesSession
set currentUserName = new notesName(notesSession.EffectiveUserName)

Each name you are comparing can be extracted from field item values
set editorNames = doc.editorNames
forall value in editorNames.values
if value <> "" then
Set editorName = new notesName(value)
End If
end forall

This might not be realistic if you have too many names too compare against, you might need to review the whole security model as it might no longer be appropriate for the current application.
Last Answered: Jun 25 2008  8:55 PM GMT by Broxy   190 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Joeydog   90 pts.  |   Jun 26 2008  2:44PM GMT

Thanks,
I can get the user name ok, but I am having trouble extracting the names fields from the document. What methods work best in Postopen?
There are 3, say okName1, okNmae2, okName3. Can you help with this?
I tried :
Dim okNameA as As notesName
Set okNameA = New notesName(notesSession.okName1)
Set user = New notesName <a href="http://notesSession.Com" title="http://notesSession.(" target="_blank">notesSession.Com</a>monUserName)
If user = okNameA Then
Source.Editmode = True
Call source.save
Source.Editmode = False
End If

but I am getting a Type mismatch error. R5.01.13

 

Brooklynegg   2685 pts.  |   Jun 27 2008  3:12PM GMT

You have no reference to the document that has the field values.

Here’s some code I put together from help information and combined with your examples. I have not tested this at all, but it should be close, assuming your user value gets set correctly. These methods should be correct for PostOpen. In your example, I don’t understand why you would save the document as soon as you force it into edit mode. I am against forcing saves. If the user makes changes and wants to save them, they can. You should give them the ability to discard changes.

Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim editorname As Variant
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
do until doc is nothing
Set user = New notesName <a href="http://notesSession.Com" title="http://notesSession.(" target="_blank">notesSession.Com</a>monUserName)
editorname = doc.okName1
if user = editorname(0) then
‘the rest of your code
end if
set doc = dc.getnextdocument(doc)
loop

 

Joeydog   90 pts.  |   Jun 30 2008  5:29PM GMT

Sorry if I haven’t made my issue clear.
I don’t need to loop through all the documents. If the user’s commonname opening the document matches either okName1, okName2, okName3 names of that document being opened, then I need that document to refresh the values in the computed fields ( RouteTo1, RouteTo2) of that document. So, when the user looks at their document it shows the correct values in RouteTo1, RouteTo2. Currently I rely on the user, opening their document to put it in Edit Mode, click Save then F9 to refresh before they route it (a button Action). But they don’t always do this and the document is being routed incorrectly.

As I tried to explain in my first post the computed fields that needs to be refreshed when opened, get their values from a view that draws from a different form (Maintain Names for Routing) that could be changed any time from a different user, but within the same db. There is no choice for the user to make, the computed fields need to refresh so that the document can route properly. PostOpen will run before the user puts any of their own changes in. Then normal Save conditions will apply for them.

I basically just need the document to refresh when opened, but only if the current user is one of those 3 okName fields. The biggest problem is understanding what PostOpen can do because if I use Call source.Save or Call source.Refresh I get a Document Command not available message. If I put it in Editmode then save, it refreshes ok, but I need it back in Read mode which causes it to loop.

This code loops:
Sub Postopen(Source As Notesuidocument)
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim NitemokName1 As NotesItem
Dim NitemokName2 As NotesItem
Dim NitemokName3As NotesItem
Dim session As New NotesSession

‘ Dim update As String <== is Global declared Initialized with a “” value
Set wksp = New NotesUIWorkspace
Set session = New NotesSession
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document

Set NitemokName1 = doc.GetFirstItem(”okName1″)
Set NitemokName2 = doc.GetFirstItem(”okName2″)
Set NitemokName3 = doc.GetFirstItem(”okName3″)

If update <> ” Change Done” And (NitemokName1.contains <a href="http://session.com" title="http://session.(" target="_blank">session.com</a>monusername) = True) _
Or (NitemokName2.contains <a href="http://session.com" title="http://session.(" target="_blank">session.com</a>monusername) = True) _
Or (NitemokName3.contains <a href="http://session.com" title="http://session.(" target="_blank">session.com</a>monusername) = True) Then
Source.Editmode = True
Call uidoc.Save
update = ” Change Done”
Source.Editmode = False
End If

End Sub

**Querymodechange checks a Status field, if Closed no edit allowed.

This is driving me crazy, I didn’t thnk this would take so long to resolve. Thanks for any help!

 

Joeydog   90 pts.  |   Jun 30 2008  5:34PM GMT

Hi Again
Just to clarify, I am now getting my user commonname to compare to these field values ok: okName1, okName2, okName3. It is the “how to refresh” without causing a loop now! If I leave out the Source.Editmode = False line, all my data is correct, but want it back to Read mode.
Thanks

 
0