Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Detecting a Change Anywhere in the Form after Opened

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

02-06-2016

Is it possible to script to detect if any change occurred since the form was opened? For example if one of the text objects now has different text or no text or if a check box is now unchecked or a dropdown slection has changed?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

09-06-2016

Hi Don,

Not sure if its the forum or not but you need a double equals,

if(event.target.dirty == true){

or, just leave the == true off

if(event.target.dirty){

Bruce

Answers (6)

Answers (6)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

04-06-2016

Hi,

You should be able to use the dirty property of the Doc object, so

event.target.dirty

Regards

Bruce

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

10-06-2016

Works great! Thanks Bruce!

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

07-06-2016

Bruce,

I guess I still don't know how to write this script. Is it something like this?

Form1:preSave - (JavaScript, client)

if(event.target.dirty = true){

Subform2.textfield2.rawValue = "Changed";

}

And I can reset the textField2 to blank each time the form is opened.

I can't get this to work. What am I missing?

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

07-06-2016

Bruce,

What I plan to use this for is updating the connected database. When the form is closed, if there have been any changes to the form, the form data is exported to the database; updating the database to match the form. If no changes have occurred since the form was opened, no export to the database occurs.

As far as your question if the user makes a change and then outs it back to the original value, reste the textField would be great but not absolutely necessary. The database data would still match the form.

Using the PreSave event seems to make sense so i will do some testing to see if I can get it to work.

I will mark your answer correct as soon as i can get this test done. Thank you for your help with this project.

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

07-06-2016

Hi Don,

I think you will need to do this in the preSave event.  The dirty flag is a per session thing, I guess it is what drives the "Do you want to save changes to ... before closing" message if you attempt to close a form without saving the changes.

So the dirty flag is always false at docOpen.

Will you need to reset the textField if the user changes the form values back to the original values (or blanks them out)?

Bruce

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

06-06-2016

Hello Bruce,

Sorry - I don't know what you mean. I want to beable to detect a change to any object on the form after the form is opened. So for example, have a text field object with a script that states if a change is made to any of the objects on the form, this text field's rawValue will equal "Changed".

So would I put your script in the Form docReady event? Something like this?

if(event.target.dirty){

textField.rawValue = "Changed";

}

Thank you for your help with this.

-Don