Pages

Tuesday, February 14, 2012

How to disable change / validation events when using loadRecord

When you use Basic.loadRecord() to load a record into a form, all of the form fields fire their change events, which you might not want. Here's a quick way to fix this:

This prevents change events from firing, but then re-enables them:

var basic = form.getForm();

basic.getFields().each(function(item, index, length){
  item.suspendCheckChange++;
});

basic.loadRecord(myRecord);

basic.getFields().each(function(item, index, length){
  item.suspendCheckChange--;

}); 

6 comments:

  1. Thank you!! I couldn't find how to do this anywhere!

    ReplyDelete
  2. This saved my butt! Thanks

    ReplyDelete
  3. Brilliant - just what I was looking for.

    Cheers!

    ReplyDelete
  4. Great it worked. I needed it for just one field.

    var basic = form.getForm();
    var field = basic.findField('name_of_field');

    field.suspendCheckChange++;

    basic.loadRecord(myRecord);

    field.suspendCheckChange--;

    ReplyDelete
  5. Wow, I couldn't thank you more, you are my angel

    ReplyDelete