File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Core ServiceNow APIs/GlideElement/Smart Field Validation and Dependent Field Derivation Using getError() and setError() Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1+ // Name: Validate Short Description
2+ // Table: Incident
3+ // When: before insert or before update
4+ // Order: 100
5+
6+ ( function executeRule ( current , previous /*null when async*/ ) {
7+ var short_desc = current . getValue ( 'short_description' ) ;
8+
9+ // Validate only for new records or when field changes
10+ if ( current . operation ( ) === 'insert' || current . short_description . changes ( ) ) {
11+ if ( ! short_desc || short_desc . trim ( ) . length < 40 ) {
12+ current . short_description . setError ( 'Short description must be at least 40 characters long.' ) ;
13+ current . setAbortAction ( true ) ;
14+ }
15+ }
16+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments