Script to update Location document

Hi,

Pls help me to get the script which will pick up the Server name and Mail file name from Person Document in NAB and update the same in Clients Location document.

Thanks.

Subject: Script to update Location document

are you actually asking someone to write you a script because you can’t do it yourself?

Subject: Script to update Location document

since I had this already, no charge!

Sub Click(Source As Button)

On Error Goto trap



Dim ns As New NotesSession

Dim nab As NotesDatabase

Dim db As NotesDatabase

Dim nabvw As NotesView

Dim pab As NotesDatabase

Dim pbvw As NotesView

Dim pdoc As NotesDocument

Dim ldoc As NotesDocument



Set db = ns.CurrentDatabase

If db.Server = "" Then

	Msgbox "Sorry, you cannot run this utility from a local mail file.", 16, "Aborting ..."

	Exit Sub

End If

Set nab = ns.GetDatabase( db.Server, "names.nsf")

Set nabvw = nab.GetView( "($Users)" )

usercn$ = ns.UserName

Set pdoc = nabvw.GetDocumentByKey( Lcase(usercn$), True)

mailserver$ = Ucase(pdoc.MailServer(0))

mailfile$ = Lcase(pdoc.MailFile(0))

maildomain$ = Ucase(pdoc.MailDomain(0))



' Add address book from mail server

' Call ws.AddDatabase( mailserver$, "names.nsf")



' Cleanup locations



Set pab = ns.GetDatabase( "", "names.nsf" )

Set pabvw = pab.GetView ( "($Locations)" )

Set ldoc = pabvw.GetFirstDocument

chg% = 0

count% = 0



While Not ldoc Is Nothing

	If Ucase(ldoc.MailServer(0)) <> mailserver$ Then

		ldoc.MailServer = mailserver$

		chg% = chg% + 1

	End If

	

	If Lcase(ldoc.MailFile(0)) <> mailfile$ Then

		ldoc.MailFile = mailfile$

		chg% = chg% + 1

	End If

	

	If Ucase(ldoc.Domain(0)) <> maildomain$ Then

		ldoc.Domain = maildomain$

		chg% = chg% + 1

	End If

	' Only save if the ldoc was modified

	If chg% > 0 Then

		Call ldoc.Save( True, False )

		count% = count% + 1

		chg% = 0

	End If

	Set ldoc = pabvw.GetNextDocument(ldoc)

Wend



If chg% = 0 Then

	Msgbox "Your current configuration is correct.", 64, "No problems found ..."

Else

	Msgbox Cstr(count%) & " Location Document(s) required corrections", 64, "Fix Location Docs ..."

End If

End

trap:

errorText$ = "Error " & Err & " at line number " & Erl & " Error: " & Error$ & " - attempting to update location docs."

Msgbox errorText$, 0, "Report this error ..."

Exit Sub

End Sub

Subject: RE: Script to update Location document

Thanks Paul for your quick responce. It works as i required…Actually i am not an developer so post it here…

Thanks

Shashikant.