230 pts.
 Creating a daily document with LotusScript.
I have created an agent to created a daily document with LotusScript.  The document creates perfectly with the agent.  This document also saves the view perfectly.  However, I am having a problem with the numbers saving in the columns of my view.  The view has three columns.  A Date column and two numeric figure columns.  I keep getting the following message in one of my columns Error:  Incorrect Data Type for operation or @Function: Number Expected. If I create this document manually without the agent.  All information saves in the columns with no problems. I am thinking that my scripts may not be correct. Here's my initialize script: Sub Initialize     Dim session As New NotesSession     Dim db As NotesDatabase     Dim doc As NotesDocument         Set db = session.CurrentDatabase     Set doc = db.CreateDocument     doc.Form = "UR"        Call doc.Save(True, True)     End Sub Here's my Click script: Sub Click(Source As Button)   ' Declare all variables     Dim workspace As New NotesUIWorkspace     Dim session As New NotesSession     Dim uidoc As NotesUIDocument     Dim view As NotesView     Dim db As NotesDatabase   'Set all variables     Set uidoc = workspace.CurrentDocument     Set db = session.CurrentDatabase     Set view = db.GetView( "Copy of Stats UR-FY11" )   'Save current document, refresh "Copy of Stats UR-FY11" view   'and close document     Call uidoc.Save     Call view.Refresh     Call workspace.ViewRefresh     Call uidoc.Close End Sub This is the first time I have ever used LotusScript. I am trying to teach myself on this.  If I made any silly errors, please forgive me and please help.. Thanks.  

Software/Hardware used:
Lotus Notes, Domino Administrator, Domino Designer Version 6.5.1
ASKED: April 15, 2011  4:00 PM
UPDATED: September 13, 2011  7:09 PM

Answer Wiki:
I suggest that you do a ComputeWithForm( True, False) on your doc object before saving it ... Voila I wrote this simple function to initialize number like "0050" in order to solve sort issue You call it like sNumber = strZero( 50 , 4) <pre> Function strZero( nombre As Long, nbLongueur As Integer) As String ' Cette fonction recoit un nombre, le transforme en string de la longueur de nbLongeur ' Les espaces devant Nombre sont complétés par des zéro Dim strANin As String, strReturn As String Dim intPadding As Integer, strPadding As String Dim nombreLength As Integer, i As Integer strANin = Cstr (nombre) nombreLength = Len (strANin) If (nbLongueur = 0) Or (nombreLength >= nbLongueur) Then ' Rien a ajouter strZero = strANin Else ' On remplace les caracteres vides par des zéro intPadding = nbLongueur - nombreLength strPadding = "" For i = 1 To intPadding strPadding = strPadding + "0" Next strZero = strPadding + strANin End If End Function </pre>
Last Wiki Answer Submitted:  May 18, 2011  2:37 pm  by  BruceWayne   4,075 pts.
All Answer Wiki Contributors:  BruceWayne   4,075 pts. , wmkelly   60 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Well, first you’ll need to tell us what the formulas are for your 3 columns. It might be helpful to know something about the fields in the documents and the values you’re inputting, too.
But, to be honest, I think you have a misunderstanding about views and documents. You don’t save views; they are just a means of seeing a list of documents and their values (to be overly simplistic). As the documents change, the values shown in the view change.

 2,700 pts.

 

Thank you so much. I failed to stated the information about my document. I didn’t mean to confuse you about the views. I totally understand that you don’t save views.

I left out the part about the document. I am creating a document daily that I want to save to a particular view. The document that I am creating details is below:

Name of document = UR

Field #1 Name = Date with @ Today = Default Field value
Field #2 Name = Population with Default formula value =
@Sum(@ToNumber(@DbColumn( “Notes” :
“”; “noteserv” : “New Neocap.nsf” ; “WRIM”; 1)))

The view contains the following:

There’s Four (4) columns in the view. Columns are as follows:

Column 1 Name= Date – with Default Field as Date
Column 2 Name = UT Rate – with Default formula as Population/125
Column 3 Name = Number – with Default formula as
@If(Population = “”;”";1)
Column 4 Name = Manday Total – with Default field as Population

When I create this document manually, I do not receive any errors in the view and the document saves to the view with no problems.

When I run the agent, the document saves to the view, but I receive the error
However, when I run the agent to create this document. I receive an error in the

UT Rate Column of the view

The Error = Error: Incorrect Data Type for operation or @Function: Number Expected.

I hope this helps. Thank you so much.

T. Will

 230 pts.

 

Thank you so much. I will see if this works. Good luck on your numeric sort as well. If I find out anything, I will try to help you as well. Thanks again.

 230 pts.

 

Whenever you have a situation where code works when you run it, but fails when it runs automatically (like on a schedule), it is often a matter of permissions. When you run it, it is executing with your permissions. When it runs automatically, it runs as the signer or whoever it is set to run as. In your case, you’re accessing a secondary db. Check the ACL of that database to be sure your agent has access to it.

 2,700 pts.

 

Thank you very much. Have a great day. I will work on this later in the afternoon.

 230 pts.

 

Thank you so much. I will work on this later in the afternoon. Have a great day.

T. Will

 230 pts.

 

I was so excited that I finally got this to fun without the error. However, when the agent runs on schedule, I receive the same error, but when I manually run the agent, I do not receive any errors.

 230 pts.

 

I finally was able to get this to work. The Error is gone. However, I scheduled the agent to run daily and when it runs, the results are blank. But if I manually go into the agent and run the agent it works. Is there something I am doing wrong. Here’s the revised code:

Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim doc As NotesDocument

Set db = session.CurrentDatabase
Set doc = db.CreateDocument
doc.Form = “Copy of UR”
doc.Date = (Date)
doc.Population = (Population)
doc.UR = (UR)
Call doc.ComputeWithForm(True,False)
Call doc.Save(True,True)

End Sub

 230 pts.