We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8fa5a66 commit 6d4a510Copy full SHA for 6d4a510
1 file changed
Client-Side Components/Catalog Client Script/Onsubmit validation/on submit scriptinclude.JS
@@ -0,0 +1,25 @@
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
+});
0 commit comments