6 Replies · Latest reply on Dec 7, 2017 1:13 AM by Abdul Azeez

    Unable to get Variable info in Server Side script in Service Portal

      Hello Experts,

       

      I am using Macro variable in that i am using widget:

       

      Here is my code:

       

      HTML:

       

      <div class="input-group ">

      <input type="text" name="name" ng-model="c.data.inputValue" />

      <button type="button" class="btn btn-danger btn-block" ng-click="c.setFieldValue()">Value</button> 

      </div>

       

      Client Controller:

       

       

      function($scope) {

                                var c = this;

                               c.setFieldValue = function() {

                              c.server.update().then(function(response) {

                                          c.data = {};

                                          var g_form = $scope.page.g_form;

                                          var values = [];

                                          values = g_form.getValue('a2');

                                         var disp = [];

                                          disp = g_form.getDisplayValue('a2');

                       if(!values){

                                                      g_form.setValue('a2', $scope.data.sysID, $scope.data.text);

                        }else{

                                                      g_form.setValue('a2', $scope.data.sysID+','+values, $scope.data.text+','+disp);      

                                          }

                              });

       

      Server Side:

       

       

      (function() {

                              if(!input)

                              return;

                  var bTab = new GlideRecord('u_backend_table');

                  bTab.initialize();

                  bTab.u_text = input.inputValue;

               bTab.u_text1 = // I want to use Variable value

                data.sysID = bTab.insert();

                  data.text = input.inputValue;

                

      })();

       

      I unable to get the Variable value at above highlighted region.

       

       

      FYI: i also tried with

      $sp.getValue('variable_name');

      $sp.getDisplayValue('variable_name');

       

       

      Nothing worked

       

       

      b-rad nathanfirth