Solved

Trouble copying field values from one form to another.

Posted on 2011-03-09
16
397 Views
Last Modified: 2013-12-18
Have an order form that I use, I am trying to add code so that when a user clicks a Submit button for the order it will send out a tracer to get approval for that order, but also open a separate order form, in this case for peripherals. They have the same common user and address fields. I have also set the second peripheral form with "Formulas inherit values from selected doc" but when I click the button with the code below it does not carry any of the values over from the order form.
Note I have one hardware doc and then a separate peripherals doc. Can I copy field values from different forms? If so what can I tweak in the code. I have tried the @Command(Compose) in a couple spots but it still carries no values over to the second form.

Any help is appreciated.
FIELD status:="Pending Approval";
FIELD submit_flag:="done";
FIELD submit_date:=@Today;
SendTo := approver;
CopyTo := "";
BlindCopyTo := bcc;
Subject := "IBPC Admin Equipment Order for " + username_hidden + " requires your approval";
Remark := "An IBPC Admin Equipment Order has been entered for " + username_hidden + ". Your approval is required. Please click on the following link and approve or reject the request.";
@Prompt([Ok];"Order Received.";"Thank you for completing this order. Your order has been received and is pending approval.");
@MailSend(SendTo; CopyTo; BlindCopyTo; Subject; Remark; "";[IncludeDoclink]);

@Command([Compose];"ibpc_order_form_peripherals");

@PostedCommand([FileSave]);
@Command([FileCloseWindow]);
@PostedCommand([FileCloseWindow])

Open in new window

0
Comment
Question by:jforget1
  • 8
  • 8
16 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35093416
A carry-over only happens if there is a default value formula in the second form. That formula uses field values from the open document.
0
 

Author Comment

by:jforget1
ID: 35094684
So if I set all the fields on the second form as editable, but use the field name as the default value would that work?
0
 

Author Comment

by:jforget1
ID: 35094917
Tried setting the defualt value on the second form to the field names, that does not bring the field values over. Is the placement of the @Command(Compose) causing me problems?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35096262
If I remember correctly, the current document is taken as source. It could be the currently selected document in a view, or a currently open document. The field's names and values are copied over to the next document, but ONLY to calculate default values (and I think also the computed fields). After that first calculation, the copied fields are discarded. So field names of the "sending" documents should be used in the "receiving" document.
0
 

Author Comment

by:jforget1
ID: 35142038
Have tried everything I can think of here. Moved the command to launch the form to various spots. Checked that all the fields have the same field name with the default value set to the same value. None of the fields transfer over. Trying to think of what I could be missing here. Will keep trying.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35143471
If you can assemble a test database with the essential forms and documents, I wouldn't mind to have a look. My mail address is in my EE profile. If you send me a mail with the zipped database, you accept to have to send it to any other expert who asks for it, since the procedure is bending the EE-rules a little.
0
 

Author Comment

by:jforget1
ID: 35147125
Thanks I have just sent over the files and what forms are involved.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35147184
...unzipped... :-P but thanks :-)
0
 

Author Comment

by:jforget1
ID: 35147205
It was zipped when I sent it. Not sure what happened after that. Appreciate you taking a look.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35147327
What *may* be the case: the Save is too late. Why use a PostedCommand? Also, if a new document is submitted, the MailDocLink won't work, for it only works with an existing document (saved). Try to change the code, somewhat like this:

FIELD submit_date:=@Today;
SendTo :="X";
CopyTo := "";
BlindCopyTo := bcc;
Subject := "xxx";
Remark := "xxx";
@Prompt([Ok];"Order Received.";"Thank you");
@Command([FileSave]);

@MailSend(SendTo; CopyTo; BlindCopyTo; Subject; Remark; "";[IncludeDoclink]);

@PostedCommand([Compose];"your_order_form_peripherals");

@PostedCommand([FileCloseWindow])
0
 

Author Comment

by:jforget1
ID: 35148136
Tried the suggestion and a few tweaks of it as well. Still not carrying over the field values to the new form.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35148442
Maybe it just isn't possible (in Formula). On the other hand, it's rather easy to do in LotusScript.

Easiest way is to prepare a NotesDocument with some fields already set, followed by an EditDocument.
0
 

Author Comment

by:jforget1
ID: 35180911
sjef, attached is LS code that I use for a tracer email in another DB. Could I use this as a starting point? How would I add in the command to open the new form and then how can I transfer the values from the current record over to the new form?
Sub Click(Source As Button)
	Dim session As New NotesSession 
	Dim db As NotesDatabase
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim ws As New notesuiworkspace
	Dim emaildoc As NotesDocument
	Dim Item As NotesItem
	Dim rtitem As NotesRichTextItem
	Dim sNamesArrB(1)As String
	Set uidoc=ws.currentDocument
	Set doc = ws.currentDocument.Document
	Set db = session.CurrentDatabase
	On Error Resume Next
	
		Set emaildoc = db.CreateDocument
		emaildoc.form = "vap_wiped_tracer" 'Form name of Letter
		emaildoc.sendto = doc.approver
		emaildoc.CopyTo = ""
		emaildoc.current_asset = doc.current_asset
		emaildoc.user_adjusted = doc.user_adjusted
		emaildoc.alt_name = doc.alt_name
		emaildoc.Subject = "Removal Request has been completed and device wiped for " + doc.user_adjusted(0) + doc.alt_name(0) +  "!"               
		Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
		Call rtitem.AppendDocLink(doc, "") 
		Call emaildoc.Send(True)
		Set uidoc = ws.EditDocument( True )
		Call uidoc.save
		Call uidoc.Close
	End Sub

Open in new window

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 35181136
As far as I can see, yes indeed, you can use some of that code.

To do:
- lines 1-15: clean up
- lines 16: use newdoc instead of emaildoc
- line 17: set the form you need
- lines 18-27: copy the fields you need from olddoc to newdoc
- line 26: remove the send
- line 27: use ws.EditDocument(True, newdoc)
- lines 28-29: remove the save+close
0
 

Author Comment

by:jforget1
ID: 35181361
I was thinking that I could update line 17 to the form that needs to go out to the user on submission. I then need to add something to create the new "peripherals" form and carry the field values from the form the user is on over to the new peripherals form that was just created in the button. Basically it is a matter of click the button, a tracer is sent for the hardware order, then a new Peripheral form is opened and key field values, shipping etc, is carried from the hardware form to the peripherals form.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 500 total points
ID: 35181598
Right, for about 99%. It's done the other way round in the code:
- first you create an new/empty document
- you set the Form field
- you set the other fields that need to have a value
- and only then you call EditDocument to show it to the user; the Form as set will be used for the display
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lotus Notes - Broken Links report 5 219
how to copy mail box rules from one nsf to another 9 183
Changing over from Lotus Approach v3 to MS Access 4 416
Domino Server 11 72
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

861 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