Edit multiple docs at once

I have 2 separate forms now for creating records in an app. They have some common data but most is different. The end-user has requested to combine both forms into one. However, there are 2 separate workflows, different reporting needs, etc. so in the back-end it would be best to keep them as 2 separate documents.

So basically, I need to allow the end-user to edit 2 separate documents from one screen (on the web).

I thought I had seen something on how to do this using javascript / ajax.

Any suggestions?

Subject: Edit multiple docs at once

I suggest you create a hidden view with view selection criteria something like… Select Process!=“True”

Create one form that holds all the field values you want stored into both forms.

After you save, have another page that appears and says; “Thank you… your documents have both been created” … or whatever text you like. Within your original form you can cause this to happen with a $$Return field that holds the name of your Thank You… such as “[ThankYou]”

Within the WebQueryOpen of your Thank You page, run the agent that looks into the view. It should find only this newly created form. You now have a handle to the backend doc that contains all the values you need for your two forms (or additional one if you want to keep this as one of the two).

Your agent creates a new backend doc, copies all items to it (or just the fields you like) then upon completion, you set the field Process=“True” in the original and it’s removed from your hidden view. Tada… two docs created but one form completed.

:slight_smile:

Subject: RE: Edit multiple docs at once

How would this work for editing those docs though? Again, when editing it would need to look like they were on one form…but save the changes to their respective documents.

Subject: RE: Edit multiple docs at once

aaah, so you want to continue to edit the one doc and you want that one doc to keep another one (or two) current.

If true, you need a method to know how to get the other docs repeatedly and dependably… one easy way could be to make the other doc(s) response docs. So as you edit the parent you can very easily get it’s child(ren) and update them too.

One concern… if you are continuing to update another doc programmically, you don’t want to do that if someone is editing the other doc at the same time (save conflicts)… I suggest you not allow editing in the other doc(s)… you could have an edit button though… it opens the parent ‘$Ref’.

To stop someone from editing it, make sure you don’t have ‘Automatically enable Edit Mode’ ON and in the postopen, put this snippet:

Sub Postopen(Source As Notesuidocument)

'this prevents edit mode on open

Dim s As New NotesSession

Dim db As NotesDatabase

Set db = s.currentdatabase

Dim uidoc As Notesuidocument

Dim w As New NotesUIWorkspace

Set uidoc = w.currentdocument

If Not uidoc.IsNewDoc Then

'this prevents edit mode on open

If source.EditMode=True Then

source.EditMode = False

End If

End If

End Sub

In the querymodechange put this snippet:

Sub Querymodechange(Source As Notesuidocument, Continue As Variant)

Messagebox(“Document available for browsing only.” )

Continue = False

Exit Sub

End Sub

When you initially create the other doc(s) in the background you can make them response docs using the MakeResponse Method.

Later when you want to update them, you can easily get a handle to them (documentCollection) with doc.getResponses();

Then interate through them with:

'Iterate Through Collection and either use an if clause or select case to handle each appropriately

Set responsedoc = collection.GetFirstDocument

While Not (responsedoc Is Nothing)

if responsedoc.GetItemValue( “Form” )(0) = “Order” Then

 'do what you want within the order doc

End if

Set responsedoc = collection.GetNextDocument(responsedoc)

Wend

That work?