Hi All,
I need to set a variable item name when creating a newdoc via LS in notes.
Here’s my problem:
I have created a variable “fieldname1”. I run the debugger and can see that I get the correct information stored within this variable but I can’t seem to transfer that information to the newdoc item when I am creating it. Please see code reference below.
(all strings and notes documents already declared, “y” is an iteger that continues to increase depending on the number of items I need to create. I have previously hardcoded a value for item(0) in newdoc)
fieldname1 = entry1.ColumnValues(1)
Messagebox fieldname1, “Value of the field” (displays the correct value I desire)
newdoc.fieldname1 = getArgumentTX(plainText, y)
The problem is that when it’s creating my items for my newdoc, the item does not register as the string (fieldname1) value, it registers as “fieldname1”.
Is there anyway I can pass a string value here to create various item names on the fly according to the value I return to fieldname1?
If so please help, hopefully I’ve just missed something small!
Thanks in advance!
-Chuck
Subject: Try: Call newdoc.ReplaceItemValue(fieldname1, “Your Value”)
Subject: RE: Try: Call newdoc.ReplaceItemValue(fieldname1, “Your Value”)
I am trying to replace the actual item not the item value…sorry I might have been unclear on this.
If variable fieldname1 = “name”
I want the code to look like this:
newdoc.name = value
not:
newdoc.fieldname1 = value
can I actually create the Notes Item dynamically?
Subject: RE: Try: Call newdoc.ReplaceItemValue(fieldname1, “Your Value”)
It’s the same thing.
You can use any string you please for the fieldname component of the method.
doc.replaceitemvalue(“name”,“whatever”)
then, you can always get the value by
doc.getitemvalue(“name”)
Trivial, really.
Subject: Did you try it? That is exactly what will happen with the following code…
Dim fieldname1 As Stringfieldname1 = “Name”
Call newdoc.ReplaceItemValue(fieldname1, “YourValue”)
will result in newdoc having a field called “Name” with the value “YourValue”
Subject: RE: Did you try it? That is exactly what will happen with the following code…
Bill’s correct Chuck. You should be able to use ReplaceItemValue to accomplish your goal.
Subject: Please Help! - Need to set a variable item in “newdoc”
Cool, an easy one 
Use the document.replaceItemValue function.
i.e. doc.replaceitemvalue(“fieldname”,newvalue)
Subject: Please Help! - Need to set a variable item in “newdoc”
Chuck, I can’t figure out what your code is doing with only the little bit you’ve posted. What’s “getArgumentTX”? What’s “plaintext”? I don’t see anywhere here where the variable “fieldname1” and therefore the value stored in it is even used again. Here’s a total guess at what you’re trying to accomplish though.
Dim s as New NotesSession
Dim db as NotesDatabase
Dim docNew as NotesDocument
Set db = s.CurrentDatabase
Set docNew = db.CreateDocument
Dim strNewValue as string
Dim entry1 as NotesViewEntry
'(set “entry1” via some LS method, i.e. view.GetEntryByKey)
strNewValue = entry1.ColumnValues(1)
’ (This actually returns the value in the second column of the view for this view entry.)
docNew.fieldname1 = strNewValue
Call docNew.Save(False, True)
This will add the NotesItem “fieldname1” to your new document with the value in the 2nd column of the view entry you’ve set.
Subject: RE: Please Help! - Need to set a variable item in “newdoc”
Thanks Keil,
It’s just a portion of a subroutine I wrote. Thanks for your help…now I’m off to try it.
-Chuck