• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

Trouble copying field values from one form to another.

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
jforget1
Asked:
jforget1
  • 8
  • 8
1 Solution
 
Sjef BosmanGroupware ConsultantCommented:
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
 
jforget1Author Commented:
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
 
jforget1Author Commented:
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: 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.

 
Sjef BosmanGroupware ConsultantCommented:
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
 
jforget1Author Commented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
 
jforget1Author Commented:
Thanks I have just sent over the files and what forms are involved.
0
 
Sjef BosmanGroupware ConsultantCommented:
...unzipped... :-P but thanks :-)
0
 
jforget1Author Commented:
It was zipped when I sent it. Not sure what happened after that. Appreciate you taking a look.
0
 
Sjef BosmanGroupware ConsultantCommented:
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
 
jforget1Author Commented:
Tried the suggestion and a few tweaks of it as well. Still not carrying over the field values to the new form.
0
 
Sjef BosmanGroupware ConsultantCommented:
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
 
jforget1Author Commented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
 
jforget1Author Commented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 8
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now