Detecting when edit form has changed...

Detecting when edit form has changed...

Postby parkerjnc » Thu Feb 14, 2013 5:39 am

I would like to know when a record is being saved if it was changed or not. If it was changed, then some code will execute under After Save, otherwise the code can be skipped.

I cannot seem to find it now, but I thought I had seen a variable somewhere that is set on the edit form when any data in the form was changed. Was I dreaming?
parkerjnc
 
Posts: 15
Joined: Wed Sep 05, 2012 12:45 pm

Re: Detecting when edit form has changed...

Postby admin » Thu Feb 14, 2013 9:55 am

parkerjnc,

beenedited is what you want.

Steven
admin
Site Admin
 
Posts: 3139
Joined: Mon Jun 15, 2009 9:53 am

Re: Detecting when edit form has changed...

Postby mlgeek » Thu Feb 14, 2013 10:41 pm

Is there any documentation on using beenedited? I've not been able to find any.
mlgeek
 
Posts: 23
Joined: Wed May 09, 2012 3:54 am

Re: Detecting when edit form has changed...

Postby parkerjnc » Fri Feb 15, 2013 5:26 am

This does not seem to be working for me. In my After Save code I want to send an email if the record was modified. When the check of #beenedited# did not work, I removed the check and added it to the body of the email so I could see the value easily. It is always '0' whether anything was changed or not. Any ideas?
parkerjnc
 
Posts: 15
Joined: Wed Sep 05, 2012 12:45 pm

Re: Detecting when edit form has changed...

Postby admin » Fri Feb 15, 2013 7:51 am

mlgeek,

There is no documentation as it was just to be used by nuBuilder its self.

parkerjnc,

You'll need to create a hack by putting some javascript on the form you want to check..


Code: Select all

$(document).ready(function () {

   e = document.createElement('input');              //-- create a hidden input
   e.setAttribute('id','has_changed');
   e.setAttribute('name','has_changed');
   $('#theform').append(e);
   $('#' + e.id).css( 'visibility', 'hidden');

   $("select,textarea,input").change(function () {
      $('#has_changed').val(1);
   });
});




Then you can use #has_changed#


Steven
admin
Site Admin
 
Posts: 3139
Joined: Mon Jun 15, 2009 9:53 am

Re: Detecting when edit form has changed...

Postby parkerjnc » Sat Feb 16, 2013 3:55 am

Excellent! Works like a charm. :D
parkerjnc
 
Posts: 15
Joined: Wed Sep 05, 2012 12:45 pm

Re: Detecting when edit form has changed...

Postby admin » Sun Feb 17, 2013 10:39 am

.
admin
Site Admin
 
Posts: 3139
Joined: Mon Jun 15, 2009 9:53 am


Return to Custom Code