URGENT : Save Response without opening

Dear all,I am currently working on an application where on saving a parent document… 5 response documents are created automatically… with all values that i want…now i want a different subjects in all the responses… which are kept as default values in respective fields in respective responses… but untill n unless i open responses go to edit mode n SAVE those responses… those values are not reflected in view…

can anyone guide me… as to how can i save the responses n and values can be reflected in view…without opening them … n manually saving those responses…

also i have created responses automatically in postsave…

Pls help me out… its really very very URGENT

Thanks in Advance…

Subject: RTFM and you will find…

  • NotesDocument.makeResponse(child document) will make a response just like it’s been saved. Running the default form formulas will have no effect.- If you full-text index your Help database it makes things a lot easier to find, if you haven’t done that yet.

  • Hope this helps…

Subject: RE: RTFM and you will find…

Using MakeResponse will not create all the fields that have been declared on the response document.

When creating documents by script you have to either use ComputeWithForm or set the fields explicitly in the script.

Subject: RE: RTFM and you will find…

Thanks … a lot every 1… computewithform worked… but got another prob… now if i reopen my parent document & apply some modifications…they are not reflected inspite of using @GetDocField($Ref; “Subject”)… what to do… please help me out buddies…

thanks a lot…

Subject: RE: RTFM and you will find…

A computed field formula calculates every time a document in the front end is created, refreshed or saved. Your response document is not in the front end when you are amending the main document so will not recalculate automatically.

In your postsave event when a main document is being saved and it is not a new document get a collection of your response documents using the Responses property of the notesdocument class and then loop through them setting the field with the subject of the main document.

Subject: RE: RTFM and you will find…

thanks matt but dont you think it will recreate all the responses again… cause currently i have the following code… in response document …

Sub Postsave(Source As Notesuidocument)

Dim session As New NotesSession 

Dim workspace As New NotesUIWorkspace 

Dim uidoc As NotesUIDocument 

Dim doc As NotesDocument 

Dim curdoc As NotesDocument 

Dim parentdoc As NotesDocument 

Dim db As NotesDatabase 

Set db=session.currentdatabase

Set uidoc = workspace.CurrentDocument 



If Not (uidoc.FieldgetText("Flag") = 1) Then 

	Call  uidoc .FieldSetText("Flag","1")

	Const ITEMSTOCOPY = {Description,ttitle,Subject,TRPlaced,Ext,TR_Email,RFPID.Body,Attachment,Location, StartDate}

	Const RESPONSEFORMS = {Response,Ready to Submit,Standard Confirmation Mail,Marketing Notes from Monster/Dice/Apply,Prospective Candidate} ' use form aliases here! 

’ Dim db As NotesDatabase

	Dim docParent As NotesDocument 

	Dim docNew As NotesDocument 

	Dim item As NotesItem 

	Dim forms, itemNames 

	

	

	

	

	

	Call uidoc.FieldSetText("Flag","1")

	

	Set docParent = Source.Document 

	Set db = docParent.ParentDatabase 

	forms = Split(RESPONSEFORMS, ",") 

	itemNames = Split(ITEMSTOCOPY, ",") 

	Forall formName In forms 

		Set docNew = db.CreateDocument 

		docNew.Form = formName 

		docNew.MakeResponse docParent 

		Forall itemName In itemNames 

			Set item = docParent.GetFirstItem(itemName) 

			If Not (item Is Nothing) Then 

				Call item.CopyItemToDocument(docNew, itemName) 

                            'Msgbox 1 

			End If 

		End Forall 

		'____________________________ validation

		

		Dim success As Variant

		

		success = docNew.ComputeWithForm( False, False )

		

		

		

	'__________________________________

		

		

		

		

		docNew.Save True, True, True 

	End Forall 

End If         

End Sub

pls help with modify the code if possible… dear…

thanks a lot matt…

ur 2 good…

thanks pls help me out dear…

Subject: RE: RTFM and you will find…

As the code stands I think it will create response documents every time it is saved but that is not the intention.

The lines

If Not (uidoc.FieldgetText(“Flag”) = 1) Then

Call uidoc.FieldSetText(“Flag”,“1”)

runs the code that create the response documents the first time the main document is saved and then set a flag so that the test will fail on further saves. As you are running the code in the PostSave event and the uidoc is not being saved again then the flag will not of been saved to the main document resulting in the test passing every time it is saved.

I would move the code to the onsubmit event which runs before the document is saved and then do something like the following.

'if new document then create response documents

If Not (uidoc.FieldgetText(“Flag”) = 1) Then

Call uidoc.FieldSetText("Flag","1")

'REST OF CODE THAT CREATES RESPONSES

Else

'existing document being saved so update responses

Dim dc as notesdocumentcollection

Dim responsedoc as notesdocument

Set parentdoc = uidoc.document

Set dc = parentdoc.Responses

Set responsedoc = dc.GetFirstDocument

while not responsedoc is nothing

    responsedoc.FIELDNAME = parentdoc.Subject(0)

    Call responsedoc.Save(True, True)

    Set responsedoc = dc.GetNextDocument(responsedoc)

wend

End If

Subject: RE: RTFM and you will find…

thanks a lot matt but m still getting an error “ILLEGAL USE OF PROPERTY” when m writting code

Sub Postsave(Source As Notesuidocument)

Dim session As New NotesSession 

Dim workspace As New NotesUIWorkspace 

Dim uidoc As NotesUIDocument 

Dim doc As NotesDocument 

Dim curdoc As NotesDocument 

Dim parentdoc As NotesDocument 

Dim db As NotesDatabase 

Set db=session.currentdatabase

Set uidoc = workspace.CurrentDocument 



If Not (uidoc.FieldgetText("Flag") = 1) Then 

'	Call  uidoc .FieldSetText("Flag","1")

	Const ITEMSTOCOPY = {Description,ttitle,Subject,TRPlaced,Ext,TR_Email,RFPID.Body,Attachment,Location, StartDate}

	Const RESPONSEFORMS = {Response,Ready to Submit,Standard Confirmation Mail,Marketing Notes from Monster/Dice/Apply,Prospective Candidate} ' use form aliases here! 

’ Dim db As NotesDatabase

	Dim docParent As NotesDocument 

	Dim docNew As NotesDocument 

	Dim item As NotesItem 

	Dim forms, itemNames 

	

	'Call uidoc.FieldSetText("Flag","1")

	

	Set docParent = Source.Document 

	Set db = docParent.ParentDatabase 

	forms = Split(RESPONSEFORMS, ",") 

	itemNames = Split(ITEMSTOCOPY, ",") 

	Forall formName In forms 

		Set docNew = db.CreateDocument 

		docNew.Form = formName 

		docNew.MakeResponse docParent 

		Forall itemName In itemNames 

			Set item = docParent.GetFirstItem(itemName) 

			If Not (item Is Nothing) Then 

				Call item.CopyItemToDocument(docNew, itemName) 

                            'Msgbox 1 

			End If 

		End Forall 

		'____________________________ validation

		

		Dim success As Variant

		

		'If Not (uidoc.FieldgetText("Flag") = 1) Then 

		success = docNew.ComputeWithForm( False, False )

		

	'End If

		

	'__________________________________

		docNew.Save True, True, True 

	End Forall 

Else

	Dim dc As notesdocumentcollection

	Dim responsedoc As notesdocument

	Set parentdoc = uidoc.document

	Set dc = parentdoc.Responses

	Set responsedoc = dc.GetFirstDocument

	While Not responsedoc Is Nothing

		responsedoc.Body1(0) = parentdoc.Description(0)    ' HERE IT PROMPTS ME THE ERROR

		responsedoc.ttitle_1(0) = parentdoc.ttitle(0)

		responsedoc.Subject_1_1(0) = parentdoc.Subject(0)

		responsedoc.Body1(0) = parentdoc.TRPlaced(0)

		responsedoc.Body1(0) = parentdoc.Ext(0)

		responsedoc.Body1(0) = parentdoc.TR_Email(0)

		responsedoc.Body1(0) = parentdoc.RFPID(0)

		responsedoc.Body1(0) = parentdoc.Body(0)

		responsedoc.Body1(0) = parentdoc.Attachment(0)

		responsedoc.Body1(0) = parentdoc.Location(0)

		responsedoc.Body1(0) = parentdoc.StartDate(0)

		

		Call responsedoc.Save(True, True)

		Set responsedoc = dc.GetNextDocument(responsedoc)

	Wend

End If

End Sub

Please kindly help me out ,

it is a bit urgent mate…

thanks in advance

Subject: RE: RTFM and you will find…

You need to move the code to the onsubmit event and uncomment out one of the lines ’ Call uidoc .FieldSetText(“Flag”,“1”) otherwise the flag will not get set and response documents will be created every time you save the main document.

The error message you are receiving is due to the way you are setting your fields. You need to drop the (0) on the fields you are setting like so

responsedoc.Body1(0) = parentdoc.Description(0)

needs to be

responsedoc.Body1 = parentdoc.Description(0)

You are also setting the Body1 field several times in your loop and every time you do so you are overwriting what was previously there. If you want several fields from the parent document to appear in this field then you need to use either the notesitem/notesrichtextitem class and AppendText or the following

responsedoc.Body1 = parentdoc.Description(0) + Chr(13) + parentdoc.TRPlaced(0) + Chr(13) + etc…

Subject: RE: RTFM and you will find…

Hey Bro!!,M still getting the same error… now this is what i have done…

Sub Postsave(Source As Notesuidocument)

Dim session As New NotesSession 

Dim workspace As New NotesUIWorkspace 

Dim uidoc As NotesUIDocument 

Dim doc As NotesDocument 

Dim curdoc As NotesDocument 

Dim parentdoc As NotesDocument 

Dim db As NotesDatabase 

Set db=session.currentdatabase

Set uidoc = workspace.CurrentDocument 



If Not (uidoc.FieldgetText("Flag") = 1) Then 

	Call  uidoc .FieldSetText("Flag","1")

	Const ITEMSTOCOPY = {Description,ttitle,Subject,TRPlaced,Ext,TR_Email,RFPID.Body,Attachment,Location, StartDate}

	Const RESPONSEFORMS = {Response,Ready to Submit,Standard Confirmation Mail,Marketing Notes from Monster/Dice/Apply,Prospective Candidate} ' use form aliases here! 

’ Dim db As NotesDatabase

	Dim docParent As NotesDocument 

	Dim docNew As NotesDocument 

	Dim item As NotesItem 

	Dim forms, itemNames 

	

	Call uidoc.FieldSetText("Flag","1")

	

	Set docParent = Source.Document 

	Set db = docParent.ParentDatabase 

	forms = Split(RESPONSEFORMS, ",") 

	itemNames = Split(ITEMSTOCOPY, ",") 

	Forall formName In forms 

		Set docNew = db.CreateDocument 

		docNew.Form = formName 

		docNew.MakeResponse docParent 

		Forall itemName In itemNames 

			Set item = docParent.GetFirstItem(itemName) 

			If Not (item Is Nothing) Then 

				Call item.CopyItemToDocument(docNew, itemName) 

                            'Msgbox 1 

			End If 

		End Forall 

		'____________________________ validation

		

		Dim success As Variant

		

		'If Not (uidoc.FieldgetText("Flag") = 1) Then 

		success = docNew.ComputeWithForm( False, False )

		

	'End If

		

	'__________________________________

		docNew.Save True, True, True 

	End Forall 

Else

	Dim dc As notesdocumentcollection

	Dim responsedoc As notesdocument

	Set parentdoc = uidoc.document

	Set dc = parentdoc.Responses

	Set responsedoc = dc.GetFirstDocument

	'While Not responsedoc Is Nothing

	responsedoc.Body1= parentdoc.Description(0) + Chr(13) + parentdoc.TRPlaced(0) + Chr(13) + parentdoc.ttitle(0) + Chr(13) +parentdoc.Subject(0) +Chr(13) +parentdoc.RFPID(0) + Chr(13) +parentdoc.Body(0) + Chr(13) +parentdoc.Description(0) +Chr(13) + parentdoc.Attachment(0) +Chr(13) +parentdoc.Location(0) +Chr(13) + parentdoc.StartDate(0)

	

	Call responsedoc.Save(True, True)

	'	Set responsedoc = dc.GetNextDocument(responsedoc)

'	Wend

End If

End Sub

pls help me…i knw it must be frustrating you…but m stucked up badly…

thanks a lot

Subject: RE: RTFM and you will find…

I have copied and pasted your code into a forms post save event and it allows me to save it ok.

Are you still getting the illegal use of property error when you try to save the code or is it when you run it? Also what line does it occur?

Subject: RE: RTFM and you will find…

when i tried to… modify already saved document… it says… variant does not contain container… at

responsedoc.Body1= parentdoc.Description(0) + Chr(13) + parentdoc.TRPlaced(0) + Chr(13) + parentdoc.ttitle(0) + Chr(13) +parentdoc.Subject(0) +Chr(13) +parentdoc.RFPID(0) + Chr(13) +parentdoc.Body(0) + Chr(13) +parentdoc.Description(0) +Chr(13) + parentdoc.Attachment(0) +Chr(13) +parentdoc.Location(0) +Chr(13) + parentdoc.StartDate(0)

at first thought i felt…i need to place body1 field in all the response documents but even after doing that … the error is irritating…buddy…what to do…??

Subject: RE: RTFM and you will find…

You do not need to place a Body1 field physically on the response form for the code to work although you will if you want to see it when you open a document.

The error is probably caused because one of the fields you are trying to copy across to the Body1 field is the incorrect type.

Until you get it working comment out this code and set it a line at a time.

responsedoc.Body1= parentdoc.Description(0) + Chr(13)

responsedoc.Body1= responsedoc.Body1(0) + parentdoc.TRPlaced(0) + Chr(13)

etc…

and then run it through in the debugger to see what line is causing the error. Then see what that fields type is in the main document. It may just be a case of converting it to a string using CStr.

Subject: RE: RTFM and you will find…

thanks a lot matt.it worked…the prob was …it was not supporting rich text field…data…to concat with…text field data…

thanks a lot dear,

take care…

Subject: URGENT : Save Response without opening…

The notesdocument computewithform method will calculate all your default value formulas.

Subject: URGENT : Save Response without opening…

After creating the responses or while creating the responses, you can update the subject. ie. After their creation for eg.

doc.responses gives you the response docs of that particular parent document. Loop thru the responses and save your subject content differently as you want…as respdoc.Subject = … etc.

Continue the code to close all these document and open the view you want and do refresh using

Call workspace.ViewRefresh

Make sure you dim the appropriate objects in the beginning of your code.