everetjo
asked on
ensure that author fields refresh/recalculate on child/response documents
when I save a parent document, it autogenerates a series of child documents. Despite having author fields on these child documents and having a least one author field with their username. these users cannot edit the created child documents.
how do i ensure that author field formulas will calculate so users can edit the child documents ?
how do i ensure that author field formulas will calculate so users can edit the child documents ?
child document generation code :
Sub QuerySave(Source As Notesuidocument, Continue As Variant)
On Error Goto catcherror
Dim sess As New Notessession
Dim doc As notesDocument
Dim varDocStatus As Variant
Set doc = Source.Document
varDocStatus = doc.DocStatus
' Check if child documents have been generated already '
If doc.ChildDocGenerated(0)<>"1" Then
If doc.DocStatus(0) = "Document Selection Approved" Then
' No need to declare doc here, we have it already '
Dim db As NotesDatabase
Set db = sess.CurrentDatabase
Dim newDoc As NotesDocument
' Generate child documents '
' first values and labels '
Dim varReqDocCheck As Variant
Dim varDocName As Variant
' second values and labels '
Dim varReqDocList As Variant
Dim varReqDocsApproved As Variant
Dim varReqDocsAppDate As Variant
Dim varReqDocCheck_1 As Variant
Dim varsysdocstatus1 As Variant
varsysdocstatus1 = "PENDING"
varReqDocCheck = doc.ReqDocCheck
varReqDocCheck_1 = doc.ReqDocCheck_1
varReqDocList = doc.ReqDocList
varDocName = doc.DocName
varDocStatus = doc.DocStatus
varReqDocApproved = doc.ReqDocsApproved
varReqDocsAppDate = doc.ReqDocsAppDate
varProdManager = doc.ProdManager
Dim i As Integer ' value counter '
i = 0
doc.DocStatus = "Document Selection Approved"
doc.ReqDocsApproved = sess.CommonUserName
doc.ReqDocsAppDate = Now()
Forall elem In varReqDocCheck
' **** create a new document object ***
Set newDoc = db.CreateDocument()
newDoc.Form = "sysspecs"
newDoc.DocManager = doc.ProdManager
newDoc.SequenceField = doc.SequenceField(0) + "-" + elem 'e.g. put field value in seq
newDoc.DocName = varReqDocCheck(i)
newDoc.SysStatus = varsysdocstatus1
newDoc.sysNumber_1 = doc.number
newDoc.sysDesignation = doc.Designation
newDoc.sysCompany= doc.Company
newDoc.sysProductrName = doc.ProductName
newDoc.DspProdManager= doc.ProdManager
newDoc.sysProdIntroDate_1 = doc.ProdIntroDate
newDoc.sysCreatedDate= doc.CreatedDate
newDoc.sysAttachments= doc.Attachments
i = i + 1
Call newDoc.MakeResponse( doc )
Call newDoc.Save( True, False, True )
End Forall
' All documents generated, '
' MARK a hidden flag field '
doc.ChildDocGenerated = "1"
End If
End If
Exit Sub ' Exit here, if no errors occur '
catcherror:
' Print error description on Status bar:
Print "ERROR in QuerySave"": " & Str(Err) _
& " " & Error$ & " on row " & Cstr(Erl)
Exit Sub
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you already have field DocManager on new form, then you can try another approach: declare authItem As NotesItem in the beginning of code, and using
doc.ReplaceItemValue and item.IsAuhtors property in code:
doc.ReplaceItemValue and item.IsAuhtors property in code:
Sub QuerySave(Source As Notesuidocument, Continue As Variant)
On Error Goto catcherror
Dim sess As New Notessession
Dim doc As notesDocument
Dim varDocStatus As Variant
Dim authItem As NotesItem ' Declare Notes item for authors field here '
Set doc = Source.Document
varDocStatus = doc.DocStatus
' Check if child documents have been generated already '
If doc.ChildDocGenerated(0)<>"1" Then
If doc.DocStatus(0) = "Document Selection Approved" Then
' No need to declare doc here, we have it already '
Dim db As NotesDatabase
Set db = sess.CurrentDatabase
Dim newDoc As NotesDocument
' Generate child documents '
' first values and labels '
Dim varReqDocCheck As Variant
Dim varDocName As Variant
' second values and labels '
Dim varReqDocList As Variant
Dim varReqDocsApproved As Variant
Dim varReqDocsAppDate As Variant
Dim varReqDocCheck_1 As Variant
varReqDocCheck = doc.ReqDocCheck
varReqDocCheck_1 = doc.ReqDocCheck_1
varReqDocList = doc.ReqDocList
varDocNAme = doc.DocName
varDocStatus = doc.DocStatus
varReqDocApproved = doc.ReqDocsApproved
varReqDocsAppDate = doc.ReqDocsAppDate
doc.DocStatus = "Document Selection Approved"
doc.ReqDocsApproved = sess.CommonUserName
doc.ReqDocsAppDate = Now()
Forall elem In varReqDocCheck
' **** create a new document object *** '
Set newDoc = db.CreateDocument()
newDoc.Form = "sysspecs"
newDoc.SequenceField = doc.SequenceField(0) + "-" + elem 'e.g. put field value in seq
newDoc.DocName = varReqDocCheck(i)
' Set Authors field content '
Set authItem = newDoc.ReplaceItemValue( "DocManager", doc.ProdManager(0) )
authItem.IsAuthors = True
newDoc.sysNumber_1 = doc.number
newDoc.sysDesignation = doc.Designation
newDoc.sysCompany= doc.Company
newDoc.sysProductrName = doc.ProductName
newDoc.DspProdManager= doc.ProdManager
newDoc.sysProdIntroDate_1 = doc.ProdIntroDate
newDoc.sysCreatedDate= doc.CreatedDate
newDoc.sysAttachments= doc.Attachments
i = i + 1
Call newDoc.MakeResponse( doc )
Call newDoc.Save( True, False, True )
End Forall
' All documents generated, '
' MARK a hidden flag field '
doc.ChildDocGenerated = "1"
End If
End If
Exit Sub ' Exit here, if no errors occur '
catcherror:
' Print error description on Status bar:
Print "ERROR in QuerySave"": " & Str(Err) _
& " " & Error$ & " on row " & Cstr(Erl)
Exit Sub
End Sub
ASKER
it still doesn't create the child documents.
Is there any error message?
ASKER
no. but if i remove the author field assignment, it creates the documents.
Sub QuerySave(Source As Notesuidocument, Continue As Variant)
On Error Goto catcherror
Dim sess As New Notessession
Dim doc As notesDocument
Dim varDocStatus As Variant
Dim authItem As NotesItem ' Declare Notes item for authors field here '
Set doc = Source.Document
varDocStatus = doc.DocStatus
' Check if child documents have been generated already '
If doc.ChildDocGenerated(0)<>"1" Then
If doc.DocStatus(0) = "Document Selection Approved" Then
' No need to declare doc here, we have it already '
Dim db As NotesDatabase
Set db = sess.CurrentDatabase
Dim newDoc As NotesDocument
' Generate child documents '
' first values and labels '
Dim varReqDocCheck As Variant
Dim varDocName As Variant
' second values and labels '
Dim varReqDocList As Variant
Dim varReqDocsApproved As Variant
Dim varReqDocsAppDate As Variant
Dim varReqDocCheck_1 As Variant
varReqDocCheck = doc.ReqDocCheck
varReqDocCheck_1 = doc.ReqDocCheck_1
varReqDocList = doc.ReqDocList
varDocNAme = doc.DocName
varDocStatus = doc.DocStatus
varReqDocApproved = doc.ReqDocsApproved
varReqDocsAppDate = doc.ReqDocsAppDate
doc.DocStatus = "Document Selection Approved"
doc.ReqDocsApproved = sess.CommonUserName
doc.ReqDocsAppDate = Now()
Forall elem In varReqDocCheck
' **** create a new document object *** '
Set newDoc = db.CreateDocument()
newDoc.Form = "sysspecs"
newDoc.SequenceField = doc.SequenceField(0) + "-" + elem 'e.g. put field value in seq
newDoc.DocName = varReqDocCheck(i)
' Set Authors field content '
Set authItem = newDoc.ReplaceItemValue( "DocManager", doc.ProdManager(0) )
authItem.IsAuthors = True
newDoc.sysNumber_1 = doc.number
newDoc.sysDesignation = doc.Designation
newDoc.sysCompany= doc.Company
newDoc.sysProductrName = doc.ProductName
newDoc.DspProdManager= doc.ProdManager
newDoc.sysProdIntroDate_1 = doc.ProdIntroDate
newDoc.sysCreatedDate= doc.CreatedDate
newDoc.sysAttachments= doc.Attachments
i = i + 1
Call newDoc.MakeResponse( doc )
Call newDoc.Save( True, False, True )
End Forall
' All documents generated, '
' MARK a hidden flag field '
doc.ChildDocGenerated = "1"
End If
End If
Exit Sub ' Exit here, if no errors occur '
catcherror:
' Print error description on Status bar:
Print "ERROR in QuerySave"": " & Str(Err) _
& " " & Error$ & " on row " & Cstr(Erl)
Exit Sub
End Sub
ASKER
Here's the current database. im not sure if something in the queryopen is causing this.
db.ProductWorkflow.4.4.8.mdb
db.ProductWorkflow.4.4.8.mdb
Error message says type mismatch error on row 58...
row contains:
newDoc.DocName = varReqDocCheck(i)
assume, i is not declared and is acting as Variant.
it's easy to fix: put back
"Dim i as Integer" to the beginning of code.
Sorry, somehow I lost it from my copy.
Then it must work. To be sure, make right-click on generated doc and see if field name DocManager is type Names. Should be.
Good luck!
row contains:
newDoc.DocName = varReqDocCheck(i)
assume, i is not declared and is acting as Variant.
it's easy to fix: put back
"Dim i as Integer" to the beginning of code.
Sorry, somehow I lost it from my copy.
Then it must work. To be sure, make right-click on generated doc and see if field name DocManager is type Names. Should be.
Good luck!
ASKER
Ok. I must have accidentally removed that line.
Im in the process of testing the author assignment. Is there a way to bring the child form directly into edit mode if you're an author ?
Im in the process of testing the author assignment. Is there a way to bring the child form directly into edit mode if you're an author ?
ASKER
The author field works, but I'm getting this error when i open the child documents. "too many recursive formula evaluations" after the error, about 25 documents open.
Some numbering code is running when child document is opened.
Is it needed?
Is it needed?
ASKER
the only numbering code should be to create the child documents and to count the versions of each child doc.
Sub QuerySave(Source As Notesuidocument, Continue As Variant)
On Error Goto catcherror
Dim sess As New Notessession
Dim doc As notesDocument
Dim varDocStatus As Variant
Dim authItem As NotesItem ' Declare Notes item for authors field here '
Set doc = Source.Document
varDocStatus = doc.DocStatus
' Check if child documents have been generated already '
If doc.ChildDocGenerated(0)<>"1" Then
If doc.DocStatus(0) = "Document Selection Approved" Then
' No need to declare doc here, we have it already '
Dim db As NotesDatabase
Set db = sess.CurrentDatabase
Dim newDoc As NotesDocument
' Generate child documents '
' first values and labels '
Dim varReqDocCheck As Variant
Dim varDocName As Variant
' second values and labels '
Dim varReqDocList As Variant
Dim i As Integer
Dim varReqDocsApproved As Variant
Dim varReqDocsAppDate As Variant
Dim varReqDocCheck_1 As Variant
varReqDocCheck = doc.ReqDocCheck
varReqDocCheck_1 = doc.ReqDocCheck_1
varReqDocList = doc.ReqDocList
varDocNAme = doc.DocName
varDocStatus = doc.DocStatus
varReqDocApproved = doc.ReqDocsApproved
varReqDocsAppDate = doc.ReqDocsAppDate
doc.DocStatus = "Document Selection Approved"
doc.ReqDocsApproved = sess.CommonUserName
doc.ReqDocsAppDate = Now()
Forall elem In varReqDocCheck
' **** create a new document object *** '
Set newDoc = db.CreateDocument()
newDoc.Form = "sysspecs"
newDoc.SequenceField = doc.SequenceField(0) + "-" + elem 'e.g. put field value in seq
newDoc.DocName = varReqDocCheck(i)
' Set Authors field content '
Set authItem = newDoc.ReplaceItemValue( "DocManager", doc.ProdManager(0) )
authItem.IsAuthors = True
newDoc.sysNumber_1 = doc.number
newDoc.sysDesignation = doc.Designation
newDoc.sysCompany= doc.Company
newDoc.sysProductrName = doc.ProductName
newDoc.DspProdManager= doc.ProdManager
newDoc.sysProdIntroDate_1 = doc.ProdIntroDate
newDoc.sysCreatedDate= doc.CreatedDate
newDoc.sysAttachments= doc.Attachments
i = i + 1
Call newDoc.MakeResponse( doc )
Call newDoc.Save( True, False, True )
End Forall
' All documents generated, '
' MARK a hidden flag field '
doc.ChildDocGenerated = "1"
End If
End If
Exit Sub ' Exit here, if no errors occur '
catcherror:
' Print error description on Status bar:
Print "ERROR in QuerySave"": " & Str(Err) _
& " " & Error$ & " on row " & Cstr(Erl)
Exit Sub
End Sub
------------------
from sysspec form
' First case: common numbering for all specs
'
Sub Postopen(Source As Notesuidocument)
If source.IsNewDoc Then
Call source.Save
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim projDoc As NotesDocument
Set doc = Source.Document
Set db = doc.ParentDatabase
Set projDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)
Dim specColl As NotesDocumentCollection
Set specColl = projDoc.Responses
Call doc.ReplaceItemValue("DocID",specColl.Count)
Call doc.Save(True,False)
End If
End Sub
How do you open child documents? Is there any code running? Formula?
ASKER
if you open a child documents from any view. it opens an amount equal to the amount of child documents created.
cpy.ProductWorkflow.4.4.8.mdb
cpy.ProductWorkflow.4.4.8.mdb
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Of course, you can add some code to check if person opening document, has rights to edit it. But in simplest form it can be done, using uidocument.EditMode property.
ASKER
FIXED! Thanks again.
ASKER
THanks again. you're a pleasure to work with.
Thank you :-)
ASKER
Open in new window