HiI have write a agent which will export data from excel Sheet.
Now i want to creat a button on the page and when i will click that button,the agent will fire. So what i will write in the button(Code).Its a web based application.
Thanx…
HiI have write a agent which will export data from excel Sheet.
Now i want to creat a button on the page and when i will click that button,the agent will fire. So what i will write in the button(Code).Its a web based application.
Thanx…
Subject: How to run a agent in Web
Hello!
Set the agent to be triggered from the agent list, and use @Command([ToolsRunMacro]; “(agentname)”).
Your agent cannot have any UI classes (or you’ll get an error), and messageboxes will show up in the server console, not to the user.
If you want to get a handle on the current document, use NotesSession.DocumentContext.
Have fun!
Steve in NYC
“It hurts to be on the cutting edge.”
Subject: RE: How to run a agent in Web
HiI have written the code below which i have written for my agent.Pls check the code and let me inform whats wrong with my code.
Dim ws As New NotesUIWorkspace
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim vw As NotesView
Dim col As NotesDocumentCollection
Dim doc2 As NotesDocument
Dim item As NotesItem
Set db = ss.CurrentDatabase
Set vw = db.GetView("vwExport")
’ *Create the COM object for
’ *the Excel file to import and hide it
Set varXLFile = CreateObject("Excel.Application")
varXLFile.Visible = False
Set varXLWorkbook = Nothing
sfic=ws.OpenFileDialog(False,"SELECT EXCEL | *.Xls","C:")
’ *Prompt for the name of the file and try to open it
strXLFilename = "EXCEL_FILE_NAME.xls"
varXLFile.Workbooks.Open sfic
Set varXLWorkbook = varXLFile.ActiveWorkbook
Set varXLSheet = varXLWorkbook.ActiveSheet
’ *Loop through all valid rows and call the
’ *function to read the values into lists
lngRow = 2
TopRow = 1
TotalR = 0 'Totle Rows
TotalNR = 0 'Totle Not Value in Field
TotalAR = 0 'Totlealready Rows
M = ""
While Not (varXLSheet.Cells(lngRow, 2).Value = "")
Key = varXLSheet.Cells(lngRow, 4).Value
Set col = vw.GetAllDocumentsByKey(Key)
If col.Count = 0 Then
Set doc = db.CreateDocument
doc.Form = "End-User Profile"
If varXLSheet.Cells(lngRow, 2).Value <> "" Then
If varXLSheet.Cells(lngRow, 3).Value <> "" Then
If varXLSheet.Cells(lngRow, 4).Value <> "" Then
If varXLSheet.Cells(lngRow, 5).Value <> "" Then
strValue = varXLSheet.Cells(lngRow, 1).Value
strValue2 = varXLSheet.Cells(lngRow, 2).Value
strValue3 = varXLSheet.Cells(lngRow, 3).Value
strValue4 = varXLSheet.Cells(lngRow, 4).Value
strValue5 = varXLSheet.Cells(lngRow, 5).Value
strValue6 = varXLSheet.Cells(lngRow, 6).Value
strValue7 = varXLSheet.Cells(lngRow, 7).Value
strValue8 = varXLSheet.Cells(lngRow, 8).Value
strValue9 = varXLSheet.Cells(lngRow, 9).Value
strValue10 = varXLSheet.Cells(lngRow, 10).Value
strValue11 = varXLSheet.Cells(lngRow, 11).Value
strValue12 = varXLSheet.Cells(lngRow, 12).Value
strValue13 = varXLSheet.Cells(lngRow, 13).Value
strValue14 = varXLSheet.Cells(lngRow, 14).Value
strValue15 = varXLSheet.Cells(lngRow, 15).Value
strValue16 = varXLSheet.Cells(lngRow, 16).Value
strValue17 = varXLSheet.Cells(lngRow, 17).Value
Call doc.ReplaceItemValue("Sample",strValue)
Call doc.ReplaceItemValue("FirstName",strValue2)
Call doc.ReplaceItemValue("LastName",strValue3)
Call doc.ReplaceItemValue("EmailAddress",strValue4)
Call doc.ReplaceItemValue("Telephone",strValue5)
Call doc.ReplaceItemValue("ManagerName",strValue6)
Call doc.ReplaceItemValue("ManagerEmailAddress",strValue7)
Call doc.ReplaceItemValue("ManagerTelephone",strValue8)
Call doc.ReplaceItemValue("CompanyName",strValue9)
Call doc.ReplaceItemValue("JobLevel",strValue10)
Call doc.ReplaceItemValue("DepartmentName",strValue11)
Call doc.ReplaceItemValue("DivisionGroupName",strValue12)
Call doc.ReplaceItemValue("Region",strValue13)
Call doc.ReplaceItemValue("Country",strValue14)
Call doc.ReplaceItemValue("Client",strValue15)
Call doc.ReplaceItemValue("CurriculumSetUp",strValue16)
Call doc.ReplaceItemValue("Status",strValue17)
Call doc.Save(True,True)
lngRow = lngRow +1
TotalR = TotalR + 1
Else
TotalR = TotalR + 1
Msgbox(TotalR)
SNo = varXLSheet.Cells(lngRow, 1).Value
V = varXLSheet.Cells(lngRow, 2).Value
C = varXLSheet.Cells(TopRow,5).Value
Msgbox(C)
’ M = C + " field are blank in " + " Name of Person is " + V & Chr(13) & “so that its Row value not add in Database” & Chr(13) & "Please Check It "
M = C & " field is blank in " & TotalR & " no. Row" & Chr(13)
TM = TM + M
lngRow = lngRow +1
TotalNR = TotalNR + 1
End If
Else
TotalR = TotalR + 1
Msgbox(TotalR)
SNo = varXLSheet.Cells(IngRow,1).Value
V = varXLSheet.Cells(lngRow, 2).Value
C = varXLSheet.Cells(TopRow,4).Value
Msgbox(C)
M = C & " field is blank in " & TotalR & " no. Row" & Chr(13)
TM = TM + M
lngRow = lngRow +1
TotalNR = TotalNR + 1
End If
Else
TotalR = TotalR + 1
Msgbox(TotalR)
SNo = varXLSheet.Cells(lngRow, 1).Value
V = varXLSheet.Cells(lngRow, 2).Value
C = varXLSheet.Cells(TopRow, 3).Value
Msgbox(C)
M = C & " field is blank in " & TotalR & " no. Row" &Chr(13)
TM = TM + M
lngRow = lngRow +1
TotalNR = TotalNR + 1
End If
Else
TotalR = TotalR + 1
Msgbox(TotalR)
SNo = varXLSheet.Cells(IngRow,1).Value
V = varXLSheet.Cells(lngRow, 2).Value
C = varXLSheet.Cells(TopRow,2).Value
Msgbox(C)
M = C & " field is blank in " & TotalR & " no. Row" & Chr(13)
TM = TM + M
lngRow = lngRow +1
TotalNR = TotalNR + 1
End If
Else
lngRow = lngRow +1
TotalR = TotalR + 1
TotalAR = TotalAR + 1
End If
Wend
TotalNE = TotalR - (TotalNR + TotalAR) 'Total New entry
Messagebox "Total No. of profiles in the Excel sheet :- " + TotalR & Chr(13) & Chr(13) & "TotalNo. of Profiles added into the database :- " +TotalNE & Chr(13) & Chr(13) & "No. of profiles not added into the database :- " + TotalNR & Chr(13) & Chr(13) & "Already Value in Row :- " + TotalAR & Chr(13) & Chr(13) &Chr(13) & "Reson of not added in Database : -" & Chr(13) & Chr(13)& TM ,,"Batch Registration Report"
varXLWorkbook.Close True
varXLFile.Quit
Set varXLFile = Nothing
Thanx a lots
Subject: RE: How to run a agent in Web
Howdy!
First of all, there is no such thing as a “NotesUI…” on the web. Scrap it. Instead of an OpenFileDialog to get the Excel file, can you just create a new one?
You can also get rid of all the msgboxes.
The agent should also be set as “Agent list selection” with “None” as the target.
If you want to export a view, there is a script much, much simpler than this. Can you just modify the view so that each cell has the proper value without doing anything in script? If so, let me know, and I can post the code later on.
Just a thought…
Ciao!
Steve in NYC
Subject: RE: How to run a agent in Web
Have you done any debugging? What line is failing? What error code? Start by adding an ON ERROR routine – this will provide more details.