I have the following script which is giving me the error "Internal Error Processing command: incorrect number of parameters.
I’m new to LotusScript and this isn’t even triggering debugger for me. Any help will be greatly appreciated.
Sub Initialize
'GET A HANDLE ON THE NOTES SESSION
Dim s As New NotesSession
'GET A HANDLE ON THE CURRENT DATABASE
Dim targetDb As NotesDatabase
Set targetDb = s.CurrentDatabase
'IF THE ENVIRONMENTAL VARIABLE IS SET
Dim empNames As String
empNames = s.GetEnvironmentValue("tmpvar")
Print empNames
'DECLARE THE DOCUMENT THAT WILL BE CREATED
Dim targetDoc As NotesDocument
'DECLARE THE NOTESDATETIME OBJECT TO BE SET
Dim dateTime As NotesDateTime
'LOOP THROUGH THE VALUES (p) OF THE FIELD AND
'CREATE A DOCUMENT FOR EACH VALUE
Dim vPeople As Variant
vPeople=s.GetEnvironmentValue("tmpvar", True)
Forall p In vPeople
'CREATE THE TARGET DOCUMENT
Set targetDoc = targetDb.CreateDocument
'IF THE TARGET DOC EXISTS, SET THE FIELD
'VALUES
If Not (targetDoc Is Nothing) Then
targetDoc.Form = "Acknowledgment"
targetDoc.empName = p
Set dateTime = New NotesDateTime(Format$(Now,"Long Date"))
Call targetDoc.ReplaceItemValue("Date",dateTime)
'SAVE THE TARGET DOCUMENT
Call targetDoc.Save( False, False )
End If
End Forall
End Sub
Subject: Incorrect Number of Parameters
Hi Angie - looks like it might be the line:
Call targetDoc.ReplaceItemValue(“Date”,dateTime)
You’re trying to set the value of ‘Date’ to be the full NotesDateTime object dateTime. You may want to use the following instead (i haven’t tested this):
Call targetDoc.ReplaceItemValue(“Date”, dateTime.DateOnly & " " & dateTime.TimeOnly)
Try this out and see if it helps.
Emily.
Subject: Incorrect Number of Parameters - Nothing works
Sorry guys, I’ve tried all of your recommendations but nothing seems to work. I’m still getting the same error and I’ve stripped my code to this.
Sub Initialize
'GET A HANDLE ON THE NOTES SESSION
Dim s As New NotesSession
'GET A HANDLE ON THE CURRENT DATABASE
Dim targetDb As NotesDatabase
Set targetDb = s.CurrentDatabase
'IF THE ENVIRONMENTAL VARIABLE IS SET
Dim empNames As String
empNames = s.GetEnvironmentValue("tmpvar")
Messagebox empNames, MB_OK, "Test"
End Sub
Subject: RE: Incorrect Number of Parameters - Nothing works
Just tried this code in a simple agent and it worked fine. Where are you using this code? Agent, action, form button…? The key to your problems might be the context the code is running in.
Emily.
Subject: RE: Incorrect Number of Parameters - Nothing works
I have a button which then calls an agent. It doesn’t seem to matter what I do I get the same error.
Thanks,
Subject: RE: Incorrect Number of Parameters - Nothing works
Some more questions to make sure we’ve got the full picture:
-
What code do you have in your button?
-
What are your agent properties - specifically the bits in the ‘Runtime’ section on the first tab?
-
Is there any more code in your agent other than in the Initialize event?
-
If your button code is LS, is there any more code other than in the Click event?
Emily.
Subject: RE: Incorrect Number of Parameters - Nothing works
Button code: tmpvar := @PickList( [Name] );
ENVIRONMENT tmpvar := @Implode(tmpvar;“,”) ;@True;
@Command([ToolsRunMacro];NMU)
Agent Settings:
Action Menu Selection
Target = None
No, no other code anywhere.
Subject: That leads to the following question what is NMU?
tmpvar := @PickList( [Name] );ENVIRONMENT tmpvar := @Implode(tmpvar;“,”) ;@True;
@Command([ToolsRunMacro];NMU)
Subject: RE: That leads to the following question what is NMU?
NMU is the alias for the agent.
Subject: Then use ""s: @Command([ToolsRunMacro]; “NMU”)
Subject: Unsuccessful attempt at bringing over environmental variable.
Thanks that helped get rid of the error but I’m still not pulling the environmental variable like I need to. I’ve verified that the notes.ini file is being updated but I can’t bring the value into a message box.
Thanks in advance!
Sub Initialize
'GET A HANDLE ON THE NOTES SESSION
Dim s As New NotesSession
'GET A HANDLE ON THE CURRENT DATABASE
Dim targetDb As NotesDatabase
Set targetDb = s.CurrentDatabase
'IF THE ENVIRONMENTAL VARIABLE IS SET
Dim empNames As String
empNames = s.GetEnvironmentValue("tmpvar")
Messagebox empNames, MB_OK, "Test"
End Sub
Button Code:
tmpvar := @PickList( [Name] );
ENVIRONMENT tmpvar := @Implode(tmpvar;“,”) ;@True;
@Command([ToolsRunMacro]; “NewManualUpdate”)
Subject: 2 things…
The @True is not needed, so:tmpvar := @PickList( [Name] );
ENVIRONMENT tmpvar := @Implode(tmpvar;“,”);
@Command([ToolsRunMacro]; “NewManualUpdate”)
Next, you want String, not Value:
empNames = s.GetEnvironmentString(“tmpvar”)
Subject: 2 things… Thanks, Bill!! Why did it work?
Thanks, Bill! That worked beautifully for me. Can you tell me what the difference is between GetEnvironmentString and GetEnvironmentValue? Why did changing it to GetEnvironmentString help?
Thanks
Subject: RE: 2 things… Thanks, Bill!! Why did it work?
Value=NumberString=String
Subject: RE: 2 things… Thanks, Bill!! Why did it work?
Ahhh, I understand! Thanks so much!
Subject: FYI …
Hi,
just in case that you missed this :-))
You can have a pure LotusScript solution for your intention. There is no need to do one part in @Formulas and the other in script. This would also solve all of your problems with environment variables.
Have a look in the Help at the “PickListStrings” method of the “NotesUIWorkspace” object.
ex.
stringArray = notesUIWorkspace.PickListStrings( PICKLIST_NAMES[, multipleSelection ] )
Bye
Hynek
Subject: RE: FYI …
Actually, in her scenario, pickliststrings would not be approriate as the sames already exist (See many earlier threads).
Angie,
I am not sure why you are putting the name sin an Environment variable. You have made huge jumps in what you have been trying to do to take this radical a step. Some context please?
Subject: Also Environment variables are not Arrays - So the Forall p In vPeople will fail.
Subject: Heh - completely missed that one!
Thinking about it - if your list of names (?) you’re getting from the environment variable is separated by commas, you could use the Split function to turn it into an array prior to your forall statement.
Emily.
Subject: Incorrect Number of Parameters
Debugging tip: If the Lotusscript debugger can’t target the cause of the error for you, try throwing in some Messagebox commands throughout the code to target the offending line. Simple Messagebox “1”, Messagebox “2”, etc. lines will help show you where the program errors out.