Solved

Trouble copying field values from one form to another.

Posted on 2011-03-09
16
390 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Lotus notes email code 2 185
Domino Server 11 62
Lotus Notes Calendar Help 6 93
Lotus Notes Mailbox (Mail Forwarding) 9 32
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
  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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now