File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Client-Side Components/Catalog Client Script/Onsubmit validation Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ var HardwareValidationUtils = Class . create ( ) ;
2+ HardwareValidationUtils . prototype = Object . extendsObject ( AbstractAjaxProcessor , {
3+
4+ validateHardware : function ( ) {
5+ var hardware = this . getParameter ( 'sysparm_hardware' ) ;
6+ var qty = parseInt ( this . getParameter ( 'sysparm_quantity' ) , 10 ) ;
7+
8+ if ( ! hardware || isNaN ( qty ) ) {
9+ return 'Invalid input!' ;
10+ }
11+
12+ var gr = new GlideRecord ( 'u_hardware_inventory' ) ;
13+ if ( gr . get ( hardware ) ) {
14+ var availableQty = parseInt ( gr . getValue ( 'available_quantity' ) , 10 ) ;
15+ if ( availableQty >= qty ) {
16+ return 'OK' ;
17+ } else {
18+ return 'Not enough stock available!' ;
19+ }
20+ }
21+ return 'Hardware not found!' ;
22+ } ,
23+
24+ type : 'HardwareValidationUtils'
25+ } ) ;
You can’t perform that action at this time.
0 commit comments