Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to add append a value to a field in the form with lotusscript

Posted on 2011-04-20
17
Medium Priority
?
1,896 Views
Last Modified: 2013-12-18
Hi,

I am a newbie to lotus and lotusscript as a matter of fact. What I need is we have domino workflow tool in my company and the domino server,we have workflows in the system.

The management asks us to enable some people to see some of the forms, so I have opened the Workflow Architect of Domino workflow and added the corresponding persons to the Readers field and activated it but this of course will only work in newly created forms. For the previously created forms I want to write a lotusscript agent that will update the ProcessReaderExpandedOS field so that those persons can see the form. I have written the following form in the initialize part of lotusscript agent.I get an error of Data not saved due to script error(s).

 script error what should i do?
0
Comment
Question by:fatihdi
  • 10
  • 7
17 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35438874
The first red line indicates that you intend to compare a NotesItem to a String, which isn't possible. The values of the item are in the Values(array), so a better comparison would be

      If item.Values(0)="Seyahat" Then

The second red line I don't understand, what do you want? item2 is already updated.

Next, what you forgot maybe: to save the document! Just before the line with GetNextDocument, add a line with
      Call doc.Save(True, False)

Finally, a warning: it could be that the type of the Readers field changes to Text instead of Names. You might have to add one more line, just before the Save()
      item2.IsReaders= True

Hope it works better after these modifications.
0
 

Author Comment

by:fatihdi
ID: 35439414
I am trying to change the field of ProcessReaderExpandedOS in the form to item2 actually...i have the desired value which is item2,want to make the value of ProcessReaderExpandedOS ,item2...how can i assign it?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35439495
The item exists in the document I hope. So what is done is correct:
- you get item2
- you add some people
- you should not assign, for the names are already added to the item
- now you have to save the document

What is your current code, just in text?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:fatihdi
ID: 35439677
Dim  db As New NotesDatabase("COROLLA\TOYOTASA","Workflow\TSAAppl.nsf")

Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim item As NotesItem
Dim item2 As NotesItem
Dim subject As String
      
Set dc = db.AllDocuments
Set doc = dc.GetFirstDocument()
      
While Not(doc Is Nothing)
            
If item="Seyahat" Then
            
Set item2=doc.GetFirstItem("ProcessReaderExpandedOS")
item2.AppendToTextList("CN=Nurgul GULER/O=TOYOTA")
item2.AppendToTextList("CN=Lutfi OZDEMIR/O=TOYOTA")
item2.AppendToTextList("CN=Tugba CORTELEKOGLU/O=TOYOTA")
Set doc.GetFirstItem("ProcessReaderExpandedOS")=item2

End if

Set doc = dc.GetNextDocument(doc)
WEND


Above is the code

Above i only try to update the ProcessExpandedReaderOS field.this field has some value but i need to add some other value to this item what could i be doing wrong?
0
 

Author Comment

by:fatihdi
ID: 35439704
The problem is I fill item2 field but it is filled from ProcessReaderExpandedOS field so I need to fill this field with values added item2.I need to assign the value of item to ProcessReaderExpandedOS field for every document in the database which has item="Seyahat" and item is filled from the ProcessOS field

thank you
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35439988
But that's the unchanged code!! Didn't you apply my earlier comments?

Maybe I don't understand you, or you don't understand me, but (once again) I'll try to explain: item2 is the field ProcessReaderExpandedOS, when you change the item the value in the document changes. If you want the values to remain changed when the agent end, you have to SAVE the document.

Proposed code below:
Dim  db As New NotesDatabase("COROLLA\TOYOTASA","Workflow\TSAAppl.nsf")

Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim item As NotesItem
Dim item2 As NotesItem
Dim subject As String
      
Set dc = db.AllDocuments
Set doc = dc.GetFirstDocument()
      
Do Until doc Is Nothing
            
	If Instr(item.Values(0), "Seyahat")>0 Then
            
		Set item2= doc.GetFirstItem("ProcessReaderExpandedOS")	
		item2.AppendToTextList("CN=Nurgul GULER/O=TOYOTA")
		item2.AppendToTextList("CN=Lutfi OZDEMIR/O=TOYOTA")
		item2.AppendToTextList("CN=Tugba CORTELEKOGLU/O=TOYOTA")
		item2.IsReaders= True
		Call doc.Save(True, False)
	
	End if

	Set doc = dc.GetNextDocument(doc)
Loop

Open in new window

0
 

Author Comment

by:fatihdi
ID: 35440113
Hi, Now I totally understand you. You tell me that if I change item2 ,ProcessReaderExpandedOS automatically change without the need to assign item2 to ProcessReaderExpandedOS.

I tried to save the agent and it did not give me any errors but after save when i tried to run it it gave the error in the screenshot...why would that happen it could not open the database....



screenshoterror.jpg
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35440258
First advice: run this first on a test database! Make a copy, and test it on that database.

Here you try to open the database Workflow/TSAAppl.nsf on server COROLLA/TOYOTASA. There are several reason why you would get that error:
- it is a new replica and it is empty
- you have insufficient rights (although I'd expect a different message)
- and the most important one: you need to open it explicitly

Replace line 1 by
      Dim db As New NotesDatabase ("", "")
      Call db.Open("COROLLA\TOYOTASA","Workflow\TSAAppl.nsf")

But if the database is actually the current database, you don't have to open it: it is open. Just use
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Set db= session.CurrentDatabase
0
 

Author Comment

by:fatihdi
ID: 35440501
Hi,

it seems like it is working but then I get another different error,saying that object variable not set.

For
1-The database is not empty all the workflow forms are here
2- I have all the rights,I am the manager with delete create agents,private agents everything...
3-I tried opening the database explicitly I get the following error. why is that? object variable not set


error.jpg
0
 

Author Comment

by:fatihdi
ID: 35440509
I have written all the code to the initialize part of the agent would that be a problem?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35440594
There's one line missing in the code:
      Set item= doc.GetFirstItem("PROCESSOS")

Consequently, item is still an object variable with nothing assigned to it.
0
 

Author Comment

by:fatihdi
ID: 35440769
Below is the code i have also included the line you mentioned, i get the object variable not set error in this code snippet.
Dim session As New NotesSession
	Dim db As NotesDatabase
	Set db= session.CurrentDatabase 
	Dim dc As NotesDocumentCollection
	Dim doc As NotesDocument
	Dim item As NotesItem
	Dim item2 As NotesItem
	Dim subject As String
	
	Set dc = db.AllDocuments
	Set doc = dc.GetFirstDocument()
	Set item= doc.GetFirstItem("PROCESSOS")
	
	Do Until doc Is Nothing
		
		If Instr(item.Values(0), "Copy_Fatih_Seyehat")>0 Then
			
			Set item2= doc.GetFirstItem("ProcessReaderExpandedOS")	
			item2.AppendToTextList("CN=Nurgul GULER/O=TOYOTA")
			item2.AppendToTextList("CN=Lutfi OZDEMIR/O=TOYOTA")
			item2.AppendToTextList("CN=Tugba CORTELEKOGLU/O=TOYOTA")
			item2.IsReaders= True
			Call doc.Save(True, False)
			
		End If
		
		Set doc = dc.GetNextDocument(doc)
	Loop

Open in new window

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35440870
item changes with every doc, so it has to be inside the loop

Move line 12 after line 14
0
 

Author Comment

by:fatihdi
ID: 35440873
If I use

 Dim db As New NotesDatabase ("", "")
      Call db.Open("COROLLA\TOYOTASA","Workflow\TSAAppl.nsf")


Then I get the error:

 Database COROLLA\TOYOTASA!! Workflow\TSAAppl.nsf has not been opened yet
0
 

Author Comment

by:fatihdi
ID: 35440935
I moved it inside the loop and it is still the same, now I assign item inside the loop but nothing has changed. although it was not inside the loop it should have been worked for 1 document and for test purpose I was aiming to modify 1 document and i checked the document , agent did not modify it somehow. what should i do?
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 2000 total points
ID: 35441023
First things first: get the database open. If the open doesn't work, check the server and database names.
0
 

Author Closing Comment

by:fatihdi
ID: 35704063
Sorry for late reponse...tnx for help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 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