Solved

Creating backend document not generating computed fields

Posted on 2004-08-26
13
293 Views
Last Modified: 2013-12-18
Hello All,
I have a lotus script that creates a backend document using fields from the current document that I have opened.
The problem is the computed fields on the backend document do not get computed.  The backend document has a dblookup to auto create a number and that field is coming out blank.  The dae field which uses @Created is coming out blank.
Is there a way to get the backend document to generate the computed fields as it does if I created it directly ????
Thanks !
Paul
0
Comment
Question by:pratigan
  • 7
  • 6
13 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 11902682
Paul,

A DOCUMENT doesn't have DbLookup's, a FORM does. So if you create a backend-document without using a form, fields (in this case you'd better talk about ITEMs) do not get computed. Add an item Form to the backend document, and use the ComputeWithForm method to force computation of all items.

Sjef
0
 
LVL 4

Author Comment

by:pratigan
ID: 11902721
Hello Sjef,
Sorry for the misconception.  I do use a form statement.  Here is the script for the generating of the backend doc.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
      Dim ss As New notessession
      Dim db As notesdatabase
      Dim ws As New NotesUIWorkspace
      Dim uidoc As notesuidocument
      Dim doc As notesdocument
      Dim backendDoc As NotesDocument
      Set db = ss.CurrentDatabase
      Set uidoc = ws.CurrentDocument
      Set backendDoc = uidoc.Document
      
      
      Set doc = db.CreateDocument
      doc.Form = "ORRform"
      doc.ORrequest = backendDoc.DisplayAuthor(0)
      doc.ORjob_nme = backendDoc.jclmember(0)
      doc.ORappl = backendDoc.Subsystem(0)
      doc.ORdesc = backendDoc.rpt1(0)
      doc.ORrpt = backendDoc.rpt1_rpt_ID(0)
      doc.ORwriter = backendDoc.rpt1_wrtr_nam(0)
      numlook = "@If(@IsNewDoc;@Subset(@DbColumn( '' : 'NoCache' ; '' : '' ; '(ORreq)' ; 1 );1)+1;ORreq)"
      doc.ORreq = Evaluate(numlook)
      doc.ORreq_Date = backendDoc.DisplayDateCreated(0)
      
      Call doc.Save(True,False)
      Call backendDoc.Save(True,False)
      
End Sub
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 11902839
And which doc is uncorrectly computed: backendDoc or doc? If it is backendDoc, I have to scratch my head, but if it is doc, then I'm right all the way, for there is no FORM involved: you just write a document and save it. Check out the ComputeWithForm method.

PS You don't have to call backendDoc.Save, it is the QuerySave of the uidoc so the document will be saved anyway (unless you set continue to False)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 11902891
Btw I assume the first 9 lines of the code in the function are pasted in, to keep things pretty standard? If not, you could remove some of the code, since uidoc= source, and db=doc.parentdatabase.
0
 
LVL 4

Author Comment

by:pratigan
ID: 11902965
Hello Sjef,
Your correct.  First, the first 9 lines are copied in.  I use them for all my scripts as a template per say.
also, doc is the document getting created.  I thought that the
doc.Form = "ORRform" statement tied the script to the form.
But you say no form is involved.
I'm currently reviewing the computewithform logic.
it appears to be used with a flag situation.  is there a way to just call it ?
flag = notesDocument.ComputeWithForm( doDataTypes, raiseError )
Parameters
doDataTypes
Boolean. The method ignores this parameter. Specify either True or False.
raiseError
Boolean. If True, an error is raised if the validation fails. If False, no error is raised; instead, the method returns False if validation fails.
0
 
LVL 4

Author Comment

by:pratigan
ID: 11903084
I think I got it.  I understand the If is checking the validation of the fomulas in the new doc.
I'll get back to you with my status.
Thanks !
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 100 total points
ID: 11903101
The statement
    doc.Form = "ORRform"
just sets an item called Form to a value. Only when the document is opened, then the value in the Form-item is used. Consequence: you can save a document without a Form-item in it, and Notes will not complain. If you would try to open that document, then Notes will complain, for it doesn't know how to present the data (using a form).

Just call
    doc.computewithform(false, false)
Then, no error will be generated, so you could end up with a document with errors in the fields. You can of course check the flag return value.
0
 
LVL 4

Author Comment

by:pratigan
ID: 11905340
aaaaaaaaaaaarrrrrrrrrrrrrrrgggggggggggg.
Well, I'm see much of a difference.  the DBcolumn to autogenerate the number field is not working and and computed field that takes the value of a previous field ajnd manipulates it isn't working.  Menaing: I have a jobname field that position 4 indicates job run frequency.
I have this in the frequency field of the new doc;
@Middle(jobname;4;1)
However if I try to do this in script as it doesn't auto generate in the new doc itself I use:
doc.ORfreq = Mid$(backendDoc.jobname$, 4, 1)
and all I get is mismatch type error.
?!?!?!?!?!?1
0
 
LVL 4

Author Comment

by:pratigan
ID: 11905437
OK.... got the frequency working... just need to get the dbcolumn on the number field to work.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 11905900
Whaddayamean? The numlook variable? I already had my doubts the first time, I fear that an Evaluate() with an @DbLookup won't work, but I'm not sure... Now I am, after reading "Using the Evaluate statement" in the Designer Help. Back to the drawing board ;)
0
 
LVL 4

Author Comment

by:pratigan
ID: 11906108
lol....
I have everything working except;
The new document to create has an auto numbering formula that performs a dbcolumn lookup on a view to get the last number used and adds 1 to it:
@If(@IsNewDoc;@Subset(@DbColumn( "" : "NoCache" ; "" : "" ; "(ORreq)" ; 1 );1)+1;ORreq)
Although its a computed field, it's not getting generated.
?!??!?!?!
Thanks Sjef.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 11906177
Why not open the view using LS?
    Dim view As NotesView

    Set view= db.getview("(ORreq)")
    set vdoc= view.getfirstdocument
    If vdoc Is Nothing Then
        doc.ORreq= 1
    Else
        doc.ORreq= vdoc.ORreq(0) + 1
    End If

:)
0
 
LVL 4

Author Comment

by:pratigan
ID: 11906282
LOL....
It's that simple.......
You made it sound too easy.
And it worked like a Charm.  
Thank you Very Much !!!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

13 Experts available now in Live!

Get 1:1 Help Now