Service Portal: Catalog item gets stuck at "Submitting..." for Mandatory variables, instead shows 400 (Bad Request) errorDescriptionWhen a user tries to submit certain catalog items from Service Portal, the page gets stuck at "Submitting...". Errors in Browser Console: uri: "api/sn_sc/v1/servicecatalog/items/bcf9c7129525d6405fabdeba66ae2a4c/submit_producer 400 (Bad Request) {error: {…}, status: "failure"} error : detail : "" message : "Mandatory variables are not filled" __proto__ : Errors in the Logs: 2018-04-18 09:21:06 (638) API_INT-thread-1 A32A62A50F691300B04F419CE1050EFC txid=61ebae2d0f2d SEVERE *** ERROR *** Root cause of JavaScriptException: com.glide.rest.service.custom.errors.ScriptableBadRequestError JavaScript evaluation error on: (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { var request_body = request.body.nextEntry(); var quantity = '' + request_body.sysparm_quantity; if (!/^\+?([0-9]*)$/.test(quantity)) throw new sn_ws_err.BadRequestError("Invalid Quantity value"); else request_body.sysparm_quantity = quantity; var itemId = '' + request.pathParams.sys_id; request_body.sysparm_id = itemId; var catItem = new sn_sc.CatItem(itemId); if (!catItem.canView()) throw new sn_ws_err.BadRequestError("Security constraints prevent ordering of Item"); var catUtil = new RestCatalogUtil(); if (!catUtil.checkMandatoryVariables(itemId, request_body.variables)) throw new sn_ws_err.BadRequestError('Mandatory Variables are required'); var cart = new sn_sc.CartJS("cart_" +itemId); request_body.sysparm_cart_name = "cart_" +itemId; try { return cart.orderNow(request_body); }catch(e) { gs.debug(e); throw new sn_ws_err.NotFoundError("Invalid Request"); } })(request, response); 2018-04-18 09:21:06 (639) API_INT-thread-1 A32A62A50F691300B04F419CE1050EFC txid=61ebae2d0f2d SEVERE *** ERROR *** JavaScript evaluation error on: (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { var request_body = request.body.nextEntry(); var quantity = '' + request_body.sysparm_quantity; if (!/^\+?([0-9]*)$/.test(quantity)) throw new sn_ws_err.BadRequestError("Invalid Quantity value"); else request_body.sysparm_quantity = quantity; var itemId = '' + request.pathParams.sys_id; request_body.sysparm_id = itemId; var catItem = new sn_sc.CatItem(itemId); if (!catItem.canView()) throw new sn_ws_err.BadRequestError("Security constraints prevent ordering of Item"); var catUtil = new RestCatalogUtil(); if (!catUtil.checkMandatoryVariables(itemId, request_body.variables)) throw new sn_ws_err.BadRequestError('Mandatory Variables are required'); var cart = new sn_sc.CartJS("cart_" +itemId); request_body.sysparm_cart_name = "cart_" +itemId; try { return cart.orderNow(request_body); }catch(e) { gs.debug(e); throw new sn_ws_err.NotFoundError("Invalid Request"); } })(request, response); org.mozilla.javascript.JavaScriptException: [object BadRequestError] (sys_ws_operation.4f9131449f901200d54dd4b4232e708d.operation_script; line 18) at org.mozilla.javascript.gen.sys_ws_operation_4f9131449f901200d54dd4b4232e708d_operation_script_4345._c_process_1(sys_ws_operation.4f9131449f901200d54dd4b4232e708d.operation_script:18) at org.mozilla.javascript.gen.sys_ws_operation_4f9131449f901200d54dd4b4232e708d_operation_script_4345.call(sys_ws_operation.4f9131449f901200d54dd4b4232e708d.operation_script) at org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2650) at org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590) at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42) at org.mozilla.javascript.gen.sys_ws_operation_4f9131449f901200d54dd4b4232e708d_operation_script_4345._c_script_0(sys_ws_operation.4f9131449f901200d54dd4b4232e708d.operation_script:1) at org.mozilla.javascript.gen.sys_ws_operation_4f9131449f901200d54dd4b4232e708d_operation_script_4345.call(sys_ws_operation.4f9131449f901200d54dd4b4232e708d.operation_script) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3428) at org.mozilla.javascript.gen.sys_ws_operation_4f9131449f901200d54dd4b4232e708d_operation_script_4345.call(sys_ws_operation.4f9131449f901200d54dd4b4232e708d.operation_script) at org.mozilla.javascript.gen.sys_ws_operation_4f9131449f901200d54dd4b4232e708d_operation_script_4345.exec(sys_ws_operation.4f9131449f901200d54dd4b4232e708d.operation_script) at com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:263) at com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:110) at com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:76) at com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:309) at com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:214) at com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:201) at com.glide.rest.service.custom.CustomService.runScript(CustomService.java:95) at com.glide.rest.service.custom.CustomService.execute(CustomService.java:82) at com.glide.rest.handler.impl.ServiceHandlerImpl.invokeService(ServiceHandlerImpl.java:36) at com.glide.rest.processors.RESTAPIProcessor.process(RESTAPIProcessor.java:271) at com.glide.processors.AProcessor.runProcessor(AProcessor.java:483) at com.glide.processors.AProcessor.processTransaction(AProcessor.java:205) at com.glide.processors.ProcessorRegistry.process0(ProcessorRegistry.java:178) at com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:167) at com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:31) at com.glide.sys.Transaction.run(Transaction.java:2038) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) 2018-04-18 09:21:06 (642) API_INT-thread-1 A32A62A50F691300B04F419CE1050EFC txid=61ebae2d0f2d #5706 [REST API] RESTAPIProcessor : Mandatory Variables are requiredCauseThe reason for these errors is hidden variables on the form which are set as Mandatory at the variable level. To investigate in detail: Look through all variables on the catalog item, and within the Variable set (if applicable).Check if the "Mandatory" checkbox is checked.For all the variables where Mandatory checkbox is checked, check if there are any Catalog UI Policies or Catalog Client Scripts which are hiding the variable from the form.If the catalog item is submitted while the hidden variable stays hidden, the system will not allow submission as it is set to Mandatory at the variable level.ResolutionUncheck the "Mandatory" checkbox on all variables which are hidden through a Catalog UI Policy or Catalog Client Script. After all Catalog UI Policies and Catalog Client Scripts are reviewed and it's determined that none of them is making mandatory variables hidden but the issue still persists, then ensure that the portal page is using the OOB widget "SC Catalog Item".Additional InformationCheck Service Portal and Client Scripts for best practices for Catalog client scripts on service portal.(un)Supported features in Service Portal