Solved

Agents

Posted on 2002-05-01
9
370 Views
Last Modified: 2013-12-18
I am new to LotusScript. Someone please help

I have an employee database application (a form) where the employee details data is entered manually by the users. The form has fields like dept, designation, location, region etc which is picked up from the respective masters using DBColumn. The names of the dept, designation etc are changed from time to time. If a dept is called 'tech' today, it might be called 'tech services' tomorrow. Changes can only be made to the dept name and not to the dept code. On change of dept name, if the user presses the update button, i would like to call an agent which would fetch all the existing records with say 'tech' and replace them with say 'tech services'. I have written the following agent. But it is bringing the documents in front of the screen while the agent is running. How can I make it run in the backend without bringing the documents in front. Also the agent needs to be web compatible. The following is the code I have used :

Sub Initialize
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim view As NotesView
     Dim doc As NotesDocument,curdoc As NotesDocument
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim vc As NotesViewEntryCollection
     
     Set db=session.currentDatabase
     Set view=db.getview("EmpV")
     Set vc=view.allentries
     Set doc=view.GetFirstDocument
     Set curdoc = session.DocumentContext
     
     While Not (doc Is Nothing)
     if curdoc.DepartmentCode(0)=doc.HidDeptCode(0)
        Then
     Set uidoc=workspace.editdocument(True,doc)
     Call uidoc.FieldSetText("EDepartment",curdoc.DepartmentDescription(0))
     Call uidoc.save(True,True)
        Call uidoc.close
          End If
          Set doc=view.GetNextDocument(doc)
     Wend
End Sub


Note : Hid DeptCode is the hidden field name in the employee form which stores the numeric value of the dept assigned.
0
Comment
Question by:c_ranjit
  • 4
  • 4
9 Comments
 
LVL 9

Expert Comment

by:Arunkumar
ID: 6985558
Do not use uidoc and fieldsettext.

Instead convert the uidoc to a otherdoc as follows...

Set otherdoc = uidoc.Document

now set the uidocs field as follows.....

otherdoc.FieldName = "VALUE"

now save the otherdoc as follows.....

call otherdoc.Save(True,False)

Thats it!

Good Luck!
Arun.
{S: Just avoid all the ui contexts...that is all needed.)
0
 
LVL 10

Accepted Solution

by:
zvonko earned 100 total points
ID: 6985566
Check this one:
Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim view As NotesView
  Dim doc As NotesDocument
  Dim curdoc As NotesDocument
 
  Set db = session.CurrentDatabase
  Set view = db.GetView("EmpV")
  Set doc = view.GetFirstDocument
  Set curdoc = session.DocumentContext
  While Not (doc Is Nothing)
    If (curdoc.DepartmentCode(0) = doc.HidDeptCode(0)) Then
      doc.EDepartment = curdoc.DepartmentDescription(0)
      Call doc.Save(True,True)
    End If
    Set doc=view.GetNextDocument(doc)
  Wend
End Sub

Regards,
zvonko

0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 6985595
haa haa haa !!!
Same thing but in a neat format...You copied my logic though.  I appreciate it...
;-)
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 10

Expert Comment

by:zvonko
ID: 6985629
Can it be copied? :))
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 6985648
Why cant ?   You did it already right ?

;-)
PS: Tell you what...100k will be ME ! I got about 1500 yesterday at this rate 7 more days i will reach 100k easily what do you say ?
0
 

Expert Comment

by:sampa
ID: 6985656
I think this is going to work well the only problem being that every time a document will be opened when the condition matches.
Just remove the line view.Allentries.
In any case u r browsing thru every doc.
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6985670
Arun, this is only working if I miss them all ;-)

Hello sampa :-)

0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 6985677
haa haa haa !!! And you got a B !!!
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6985706
OK c_ranjit, you are new to this community so let you be explained this: grading are NOT school gradings!

Click on the link below for more explanations :-)

Thank you for the points, but some kind feedback would also do well (if it does not cost too much of your valuable time :-)

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Missing Rules 1 301
How many GB is a good number to keep these databases? 6 177
Connect SQL Server from Lotus Domino Application 7 347
how to install domino server on suse linux 18 81
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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