How to save a blank exemplar of the current form?

shawnFMU

17-09-2018

Is it possible to have a button that performs a "save as" and "reset" without actually resetting the current state?
So literally a button that saves another blank exemplar of the form itself without deleting the current entries.

Thank you in advance

Accepted Solutions (1)

Accepted Solutions (1)

MinusZero

17-09-2018

One way to achieve this would be this. In the form's presave event, create variables for all your object values and then reset the form and in the postsave event, restore all the object values from the variables. Presave events take place before the save dialog, postsave event execute after the dialog closes. Note: it will trigger if the user cancels as well.

This will require the creation of global variables. I wrote a bit about global variables here: How to compare global variable value to TextField value

Answers (2)

Answers (2)

MinusZero

18-09-2018

Great stuff. Sometimes the simplest option is the best. All my code is very uncomplicated, it is larger, but it works which is my desired outcome.

shawnFMU

18-09-2018

Great insight MinusZero!

Plus your write up on Global Variables help me piece together a working button.

I don't think my version is the most effective, but it seems to work.

For everyone else interested here's my proof of concept:

1Text Field Object: "Test1"

1 Button Object: "SaveBlank"

Insert a Script Object: "Memory"

Memory

var Test1X = Test1;

Test1

// initialize event //

this.rawValue = Memory.Test1X;

this.rawValue = "";

SaveBlank

// click event //

app.execMenuItem("SaveAs");

//preSave event //

Memory.Test1X.rawValue = Test1.rawValue;

//postSave event //

Test1.rawValue = Memory.Test1X.rawValue;

Soo, type some text in Test1 field. Click on the button. prompts a "save as" window. Save.

Your inputted text remains, but a blank form is saved. Yeah.

Some might be going "hey! you didn't reset the fields."

I say, "yeah... it seems I don't need to.. I don't know really why, but ehh..."

I'm thinking its because I threw in the this.rawValue=""; in the Text Field Object, the strange Test1X = Test1 loopy thing, and order of operations, all happening in a mishaps of desired outcome.

Good luck!