Widget Code to pass data from HTML to Server Script
HTML
<div> <input type="text" id="tysupport" ng-model="c.data.model.support" class="form-control"><br> <button ng-click='submitTicket()'>click</button> <p></p> </div>
Server Script
(function() { var createCase = function(case_data) { gs.addInfoMessage("case_data.support" + case_data.support); var gr = new GlideRecord("sys_useer"); gr.initialize(); gr.name = case_data.support; gr.insert(); }; if (input.action === 'newCase') { var case_data = input.case_data; try { createCase(case_data); data.success = true; } catch (e) { data.err = e; data.success = false; } } })();
Client Controller:
api.controller = function($scope) { /* widget controller */ var c = this; $scope.submitTicket = function() { c.server.get({ action: 'newCase', case_data: c.data.model }).then(function(response) { alert("Record Successfully inserted"); }); }; };
Widget Code to pass data from HTML to Server Script and insert in ServiceNow table.
Working Code Edited question July 6, 2023