Creating backend document not generating computed fields

Posted on 2004-08-26
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 !
Question by:pratigan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
LVL 46

Expert Comment

by:Sjef Bosman
ID: 11902682

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.


Author Comment

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
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)
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.

Author Comment

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 )
Boolean. The method ignores this parameter. Specify either True or False.
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.

Author Comment

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 !
LVL 46

Accepted Solution

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.

Author Comment

ID: 11905340
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;
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.

Author Comment

ID: 11905437
OK.... got the frequency working... just need to get the dbcolumn on the number field to work.
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 ;)

Author Comment

ID: 11906108
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.
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
        doc.ORreq= vdoc.ORreq(0) + 1
    End If


Author Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Suggested Courses

734 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