Changing form name back to original form

Hi, all,

From reading many posts on this topic, I understand that a document’s form name will change, the first time it is edited in a view with a form formula. How can you change it back to the original form name so that it will continue to appear in views using that form?

I already have a Computed field with the original form name as the formula, but this does not prevent the form name from changing when the doc is edited in the view with the form formula. Coding it into the Querysave event does not change it back, and putting it into the Postsave event would necessitate saving, which would then put it into an endless loop.

Does this mean I have to modify all view selection formulas to include both form names and put form formulas in all the views using the original form, so that the form name changes every time it is edited in one or the other type of view??

TIA

Mark

Subject: Changing form name back to original form

No, PostSave code will not put it into a loop. You can’t do a NotesUIDocument.Save, since that will overwrite the Form field value and run the PostSave event, so you’d do a NotesDocument.Save, which does not trigger the QuerySave or PostSave event code. You would also have to set a SaveOptions field to “0”, though, to prevent the document from trying to save again when the user closes it (so using the QueryClose and checking the edit mode is probably your best bet anyway).

Subject: RE: Changing form name back to original form

Stan,

Thanks so much for responding. I tried the code in the QueryClose event, and it didn’t work, but I think I understand what is happening now: I open a “Form A” doc in a view with a Form B form formula. When the doc is edited, the form name changes to “Form B.” My code never runs because it is in the QC event of Form A, and the doc is now a B - right?

So I have to move the code into the QC event of Form B and determine whether the doc should be changed (back) to an A.

Am I right, or am I confused?

Subject: RE: Changing form name back to original form

More right than confused, for sure. If you allow documents from multiple forms to be edited using a single form in your form formula, though, you will need to store the original form value somewhere so that you can reset it.

Subject: SOLVED re: Changing form name back to original form

I created a new Comp When Comp field on Form A, with a formula of “1” to flag the doc as having been created with Form A. I also added it to Form B (editable, with the field name as the default value). Then I moved the QueryClose code from Form A to Form B, since the doc has changed into a Form B doc by the time QC trips. Lastly, I modified the code to run only if the flag field is “1” and the uidoc is in Edit mode. That way, Form B’s remain Form B’s, and docs which used to be Form A’s are changed back to Form A’s.

THANK YOU for helping me with this! It was making me crazy, and I learned a lot.

Mark