Testing for a Valid Record

Today 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!');
}

Date Posted:

June 17, 2010

Share This:

Categories

Tags

Loading

Fresh Content
Direct to Your Inbox

Just add your email and hit subscribe to stay informed.