-3

Hi Friends i am very new to lotus notes and i have a query which i am not able to solve.

I have created a agent with lotus script in lotus notes which generates text file with the View Details.

Option Public
Sub Initialize  
    MsgBox " Agent AccessUserList"
    On Error GoTo HandleError   
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim view As NotesView
    Dim embobj As NotesEmbeddedObject
    Dim rtitem As NotesRichTextItem
    Dim ErrMsg As String
    Dim dateTime As New NotesDateTime( "" )
    dateTime.LSLocalTime = Now
    UserListDate = dateTime.DateOnly
    TheDate=Format(Now(),"mmdd")    
    filename =  CurDrive$()+"\color\"+"Colors_" +TheDate+"Selection_OP" +".txt"
    MsgBox filename
    Set db = session.CurrentDatabase    
    On Error GoTo LogErr    
    Dim v As NotesView
    Dim s As New NotesSession
    Dim ec As NotesViewEntryCollection
    Dim ent As NotesViewEntry
    Dim filePath As String, valString As String
    Dim myStream As NotesStream
    Dim fileNum As Integer, count As Integer, x As Integer
    Set myStream = s.Createstream()
    Call myStream.Open(filename, "ASCII")
    Call myStream.Truncate()
    Set db = s.CurrentDatabase  
    MsgBox "BEFORE ENTER VIEW"



    'Call myStream.Writetext(i.Title, 0)
    Set v = db.GetView("SelectCustomer")    
    MsgBox "Entered View"
    If (v Is Nothing) Then
        MsgBox "View  does not exist"
    Exit Sub
    End If  
    count = v.Columncount
    ForAll i In v.Columns

        If i.Position = count Then
            Call myStream.Writetext(i.Title, 0)
        Else
            Call myStream.Writetext(i.Title & "||")
        End If
    End ForAll

    MsgBox "AFTER COLUMN"
    Set ec = v.Allentries
    Set ent = ec.Getfirstentry()
    While Not ent Is Nothing
        x = 1
        ForAll j In ent.Columnvalues
            If IsArray(j) Then
                valString = |"| & Join(j, ",") & |"|
            Else
                If InStr(j, ",") > 0 Then
                    valString = |"| & j & |"|
                Else
                    valString = j
                End If
            End If
                If x = count Then
                Call myStream.Writetext(valString, 0)
            Else
                Call myStream.Writetext(valString & "||")
            End If
          x=x+1
        End ForAll
        Set ent = ec.Getnextentry(ent)
    Wend
    closeFile:
    Call myStream.Close()
Exit Sub
HandleError:     
    MsgBox "Error  - " & Error &" at line number  " & Erl
    Exit Sub
    LogErr:
    Resume closeFile
    Exit Sub

End Sub 

This is above code which generates the file in server with the details.

But i want only the empty file which generates everyday when i start the crone in the particular folder I tried to remove all the unwanted code but if i comment any code i will not get error but the file will never get generated.

*Can anyone help me to edit this code i need to generate simple empty text file everyday which all the lines i should edit in this code *

Thanks for your time and help.

  • 2
    I have NO IDEA what you want... If you want an empty file, then you need these four lines of code (semicolon is the line delimiter), `Set myStream = s.Createstream();Call myStream.Open(filename, "ASCII");Call myStream.Truncate();Call myStream.Close()` – Tode Jul 22 '16 at 13:34
  • #Torsten Yes u got me correctly i need a to create a empty file in server through agent but if i run the code i am getting error as Error -Variant does not contain an object at line number 10 – sandeep_vibrancy Jul 23 '16 at 21:25
  • But one thing is that the agent is getting triggered with no errors but file is not getting created in the server . The timings in the particular folder is changed in remote server but the folder is empty . No file created #Emmanuel @TorstenLink – sandeep_vibrancy Jul 23 '16 at 22:24

1 Answers1

0

If I understand you just want to generate a empty file, below changes in your code. I still don't understand what you tried and what you get. don't forget that stackoverflow is not a hire a developer for free area ;-) Next time show which effort you've done!

Option Public
Sub Initialize  
    On Error GoTo HandleError   
    Dim session As New NotesSession
    dim TheDate as string, filename as string
    TheDate=Format(Now(),"mmdd")    
    filename =  CurDrive$()+"\color\Colors_" +TheDate+"Selection_OP.txt"
    'MsgBox filename

    Dim myStream As NotesStream
    Set myStream = s.Createstream()
    Call myStream.Open(filename, "ASCII")
    Call myStream.Truncate()
    Call myStream.Writetext(" ") 'this shouldn't be necessary
closeFile:
    Call myStream.Close()
Exit Sub
HandleError:     
    MsgBox "Error  - " & Error &" at line number  " & Erl
    Exit Sub

End Sub 
Emmanuel Gleizer
  • 1,990
  • 16
  • 26
  • #Emmanuel Sorry for In Convenience. The truth is i tried removing the code for creating a file with the date . . I dont have anything in mind to hire free developer. While adding the question i am not able to express correctly my question thats the problem. – sandeep_vibrancy Jul 23 '16 at 21:20
  • But one thing is that the agent is getting triggered with no errors but file is not getting created in the server . The timings in the particular folder is changed in remote server but the folder is empty . No file created #Emmanuel – sandeep_vibrancy Jul 23 '16 at 22:23
  • when you say the agent is getting triggered. you see the print in the log.nsf ? Could you please also check and post here the value of filename ? – Emmanuel Gleizer Jul 24 '16 at 08:12
  • also could you precise what is the trigger of your agent (I guess schedule On schedule Daily) please check also the security level of your agent. – Emmanuel Gleizer Jul 24 '16 at 08:19