Solved

Creating backend document not generating computed fields

Posted on 2004-08-26
13
300 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
[X]
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
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
Independent Software Vendors: 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.
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

623 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