Solved

I need to assign a value to a field in a document in lotusscrip dynamically

Posted on 2011-09-15
3
338 Views
Last Modified: 2013-12-18
I have 100 fields in a form ., when i create a document . i need to assign values to those fields
but i dont want to write all 100 fields manually  because their name are like

field1
field2
field3
field4
.
.
.                       that goes like that

so i put a for loop in the for loop preceding the string "field"  appended by counter value of the for loop i get the name of the field and then try to assign value to it but i get the error

use of illegal property  below is my code. how can i achieve this?

      For x=0 To datacount  
            
                  doc.KHedef&Cstr(x+1)="value1"                                                             doc.Ilgilihoshin&Cstr(x+1)="value2"
                  doc.HedefBitis&Cstr(x+1)="value3"
                  doc.BasariOlcum&Cstr(x+1)="value4"
                   doc.Agirlik&Cstr(x+1)="value5"

                  
                        

      Next      
0
Comment
Question by:fatihdi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:fatihdi
ID: 36544272
error screenshot
0
 
LVL 10

Accepted Solution

by:
doninja earned 300 total points
ID: 36544336
try using doc.replaceitemvalue(itemname$,value)

you can specify the field name as a string

i.e.
in declarations
dim item as notesitem

in code
set item=doc.replaceitemvalue("KHedef"  & Cstr(x+1), "value1")

repeat for each variable you have to define.
0
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 200 total points
ID: 36546578
Or, shorter

Call doc.replaceitemvalue("KHedef" & (x+1), "value1")

If would even make sense to store the strings in an array, and loop through that one too, like this:

Dim fields As Variant
fields= Split("KHedef;HedefBitis;others", ";") ' to create an array
For x=1 To datacount  +1                             ' why fro 0 to datacount?
      Forall fld In fields
            Call doc.replaceitemvalue(fld & x, "value1")
      End Forall
Next

Of course, the values can be put in an array as well...
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question