Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

Creating backend document not generating computed fields

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
pratigan
Asked:
pratigan
  • 7
  • 6
1 Solution
 
Sjef BosmanGroupware ConsultantCommented:
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
 
pratiganAuthor Commented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Sjef BosmanGroupware ConsultantCommented:
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
 
pratiganAuthor Commented:
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
 
pratiganAuthor Commented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
 
pratiganAuthor Commented:
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
 
pratiganAuthor Commented:
OK.... got the frequency working... just need to get the dbcolumn on the number field to work.
0
 
Sjef BosmanGroupware ConsultantCommented:
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
 
pratiganAuthor Commented:
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
 
Sjef BosmanGroupware ConsultantCommented:
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
 
pratiganAuthor Commented:
LOL....
It's that simple.......
You made it sound too easy.
And it worked like a Charm.  
Thank you Very Much !!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

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