g_form.isNewRecord() gs equivalent

kungfuu72
Giga Expert

Is there a gs equivalent to the g_form.isNewRecord() ?

 

I find this very useful in client scripts, but sometimes, I see myself wanted to use this in UI Actions that are not client-based as well...

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

current.isValidRecord() is what you're looking for.   This SNGuru article explains the usage of both...



http://www.servicenowguru.com/scripting/client-scripts-scripting/testing-valid-record/


View solution in original post

5 REPLIES 5

prdelong
Kilo Guru

I'm not sure there is a GlideSystem equivalent of g_form.isNewRecord(). However there is a GlideRecord function identical to it isNewRecord(). It sees whether or not the record has been inserted into the DB yet. I believe it is usable with the 'current' variable.


Yes you are correct:



Reference GlideRecord - ServiceNow Wiki



Thanks!


Mark Stanger
Giga Sage

current.isValidRecord() is what you're looking for.   This SNGuru article explains the usage of both...



http://www.servicenowguru.com/scripting/client-scripts-scripting/testing-valid-record/


I see the difference between the 2 calls now:



current.isNewRecord() returns true only if the newRecord() method has been called.

current.isValidRecord() returns true if table is valid or if record was successfully fetched, or false if table is invalid or record was not successfully fetched.