Solved

Author Fields and Agents

Posted on 2003-12-11
11
498 Views
Last Modified: 2013-12-18
I am currently writing an agent which I want to place on my Quickplace server.

The agent updates the values which are held in the reader and author field.  The code for the agent is below.

The problem I am having is that when the user first submits the document the only name in the author field the the users.  When the agent runs on the document it does not update the document.  

Is this because of the author field or am I missing something?  The agent has been signed by the server.

Is there anything I have missed?

-------------------------------------------

Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim groupmembers As Variant
Dim rfield As NotesItem
Dim afield As NotesItem
Dim collection As NotesDocumentCollection
Dim dt As New NotesDateTime("")
      
Set db = s.CurrentDatabase      
'Search for document with the workflow stage h_Submitted and h_New
Set collection = db.Search("@Contains(h_workflowStage;'h_Submitted':'h_New')",dt,0)      
Set doc = collection.GetFirstDocument      
      
'Process Documents
While Not(doc Is Nothing)            
      workflow = doc.h_workflowStage(0)       
      If workflow = "h_Submitted" Then
            If Not doc.HasItem ( "UpdatedDLAUsers" ) Then
                  Call SetGroupMembers(db,doc,"DLA_Admin")
            End If
      Elseif workflow = "h_New" or workflow = "" Then
            If Not doc.HasItem ( "UpdatedClientUsers" ) Then
                  Call SetGroupMembers(db,doc,"Client_Agent")
            End If
      End If
      Set doc = collection.GetNextDocument(doc)
Wend
End Sub

Sub SetGroupMembers(db As NotesDatabase, doc As NotesDocument,param As String)
      
Dim dbpath As String
Dim groupview As NotesView
Dim groupdoc As NotesDocument
Dim groupMembers() As String
Dim updateditem As NotesItem
Redim Preserve groupmembers (0)
groupmembers (0) = ""
strMembersDBFilename = "Contacts1.nsf"
dbpath=Strleft(db.filepath,"Main.nsf",5)
      
'Gets the members of the appropriate group
Dim membersdb As New NotesDatabase ( db.Server, dbpath + strMembersDBFilename)
Set groupview = membersdb.GetView("h_Groups")
Set groupdoc = groupview.getfirstdocument
Do While Not groupdoc Is Nothing
      If groupdoc.h_Name(0) =param Then
            group = groupdoc.GetItemValue ( "h_Members" )
            i=0
            Forall x In group                        
                  Redim Preserve groupMembers ( 0 To i )
                  IsinArray = Arraygetindex (groupMembers,x,5)
                  If Isnull(IsInArray) Then
                        groupMembers (i) = x
                        i = i + 1
                  End If
            End Forall
      End If
            
      'Updates Next Stage User i.e. Authoriser
      If param="DLA_Admin" Then
            If doc.HasItem ( "h_SetNextStageUser" ) Then
                  Set rfield = doc.GetFirstItem( "h_SetNextStageUser" )
                  currentUsers = doc.GetItemValue( "h_SetNextStageUser" )
                  Forall m In groupMembers
                        IsinArray = Arraygetindex (currentUsers,m,5)
                        If Isnull(IsInArray) Then
                        Call rfield.AppendToTextList (groupMembers)
                        End If
                  End Forall
            Else
            Set rfield = New NotesItem ( doc, "h_SetNextStageUser", groupMembers )
            End If
      End If
            
      'Updates Reader field
      If doc.HasItem ( "h_Readers" ) Then
            Set rfield = doc.GetFirstItem ( "h_Readers" )
            currentUsers = doc.GetItemValue( "h_Readers" )
            Forall m In groupMembers
                  IsinArray = Arraygetindex (currentUsers,m,5)
                  If Isnull(IsInArray) Then
                        Call rfield.AppendToTextList (m)
                  End If
            End Forall
      Else
            Set rfield = New NotesItem ( doc, "h_Readers", groupMembers )
      End If
      
      'Updates Author field
      If doc.HasItem ( "h_Authors" ) Then
            Set rfield = doc.GetFirstItem ( "h_Authors" )
            currentUsers = doc.GetItemValue( "h_Authors" )
            Forall m In groupMembers
                  IsinArray = Arraygetindex (currentUsers,m,5)
                  If Isnull(IsInArray) Then
                        Call rfield.AppendToTextList (m)
                  End If
            End Forall
      Else
            Set rfield = New NotesItem ( doc, "h_Authors", groupMembers )
      End If
      Set groupdoc=groupview.getNextdocument(groupdoc)
Loop

'Saves Document
Call doc.Save (True,True)
End Sub
0
Comment
Question by:fayeb
11 Comments
 
LVL 31

Accepted Solution

by:
qwaletee earned 200 total points
ID: 9922385
I really don't want to wade through fifty lines of code, and then try to debug what part os wrong.  Can  make a sugestion that will make this easier to deal with?

First, create a test form instead of your current form.  Then, create a test agent to work with that test form.  Make teh agent very small, only testing the ability to update the author field (not even the reader field).

Once we get that working, it will probably be obvious how to fix the longer agent that is associated with the real form.

OK?
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 200 total points
ID: 9922428
Is this agent a scheduled one ?

If this is scheduled one.. and agent signer is server then you have to include a role (assigned to server in ACL) or server name in the author field. What you can do is create another Author field and set Admin role as default. Assign this admin role to the server and admin group.

Since the author of the doc is user, server doesn't have authority to edit the document. You can see error about security in the notes log when the agent runs.

Include server name/role to the document authors.

~Hemanth
0
 
LVL 9

Assisted Solution

by:Arunkumar
Arunkumar earned 50 total points
ID: 9922640
Always have a role assigned to the Db which is super Role to access all documents.  Make this role available for All administrators and all servers in the domain.

Make sure that this role goes into a separate field Author / Reader ALWAYS.

Now, if you run your agent by server id or any adminsitrator want to do STUFF they have access to all the documents in the Database.  Its always a good practice cause you wont lose any document permanently due to the presence of reader fields.

Good Luck!
Arun.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9923315
Uh, guys, remember, this is Quickplace.  You normly set up agents as text files that you upload to an agent screen in Quickplace, and there is no agent signing authority to worry about, since Qickplace takes care of it.
0
 
LVL 15

Assisted Solution

by:Bozzie4
Bozzie4 earned 50 total points
ID: 9940347
Do you have these fields on your form : UpdatedDLAUsers ?

Because then your check will make sure the document in not updated  
(If Not doc.HasItem ( "UpdatedDLAUsers" ) Then ...)

Remove those lines (well, comment them out) and try again.

Also, add some debugging : use print lines if you have this agent scheduled (on new/modified documents, I suppose).  This will print information to the server log.

And last: if you run this agent when clicking a button, you won't see the changes in the front-end until you reload the ui....

cheers,

Tom
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 31

Expert Comment

by:qwaletee
ID: 9940351
qwaletee,

Once more,

> Uh, guys, remember, this is Quickplace.  You normly set up agents as text files that you
> upload to an agent screen in Quickplace, and there is no agent signing authority to worry
> about, since Qickplace takes care of it.


- qwaletee
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9942318
fayeb, to make things more clearer log the agent activities using print statements or using noteslog object.. Whichever is convenient !

BTW, When & how is this agent run  ?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9942433
Coming back to Qwaletees remark

> Uh, guys, remember, this is Quickplace.  You normly set up agents as text files that you
> upload to an agent screen in Quickplace, and there is no agent signing authority to worry
> about, since Qickplace takes care of it.


The agent which has been submitted by the user (access rights determined at the run time) is run by server using the agent signer (the user who submitted the agent) access on the server.

So effectively the problem is still with agent signing.. so there should be a admin role which should also have author access to the document. If the user who submitted the document only has the access then you are never going to be successful in running the agent on that document. This is true for scheduled agents.

If the user who submit the document invoke the agent then his user credentials are used.

Ultimately the answer to this question lies on how the agent is invoked ?



0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9954753
Hemanth,

QuickPlace runs agents under the authority of the place owner.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9954966
See http://www-1.ibm.com/support/docview.wss?uid=swg21090191 and http://www-1.ibm.com/support/docview.wss?uid=swg27002693

And I'm wrong.  SCHEDULED agents run with the submitter's authority, and form agents run, I think, with the submitter's authority, but neither requires signing.
0
 

Author Comment

by:fayeb
ID: 9963289
I still haven't completely solved this one.  

I have found a work around by placing the agent directly into the database design and signing it with the server ID, this now works.

It does seem that the agent is run as the person who places the placebot however even when I did this with someone who had manager access it did not work as it should do.

Thanks for all of you comments.

I will split the points between you all as you all have helped point me a some direction!

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now