Testing for a Valid Record

///Testing for a Valid Record

Testing for a Valid Record

T

oday I came across a scripting issue that I actually see quite often. I can’t ever remember it when I need it so I’m going to document it here. The issue is this: when working in a client script or business rule, I need to only have the script run if the record is a valid record. For me, this issue really only comes into play when working with client scripting or UI policies. For example, I only want a script to run if the record hasn’t been submitted yet. The following scripts show how you can test if a record is a new record or not in your scripts.

Business Rule / UI Action:

//Check if new record
current.isValidRecord();

You’ll often see a condition like this on UI actions indicating that the UI action should only be available if the record has actually been inserted already…

!current.isValidRecord()

Client Script:

//Check if new record
if(g_form.isNewRecord()){
   alert('This is a new record!');
}
By | 2018-07-09T15:00:09-06:00 June 17th, 2010|Categories: Client scripts|Tags: , , |0 Comments

About the Author:

Leave A Comment