The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Input on server script is undefined on c.server.update()

johnny27
Tera Contributor

One of my work instances, the input variable on the server script remains undefined instead of being updated to a catalog item sys id whenever the select picker changes value. The correct behavior should list the name of the catalog item below the select option.

Build date: 07-16-2017_1252

Build tag: glide-istanbul-09-23-2016__patch7-hotfix1-07-15-2017

MID buildstamp: istanbul-09-23-2016__patch7-hotfix1-07-15-2017_07-16-2017_1252

Load-balancer status: Online

HTML

<div class="row">

      <div class="col-sm-12">

              <select ng-change="selectCatItem()"

                              ng-model="c.data.selectedCatItem"

                              ng-options="catItem.sys_id as catItem.short_description for catItem in c.data.catItemList">

              </select>

      </div>

</div>

<div class="row">

  <div class="col-sm-12">

      {{c.data.curCatItem.short_description}}

  </div>

</div>

Client Script

function($scope) {

  /* widget controller */

  var c = this;

$scope.selectCatItem = function() {

console.log("onSelect",c.data.selectedCatItem);

c.server.update();

}

}

Server Script:

(function() {

  /* populate the 'data' object */

  /* e.g., data.table = $sp.getValue('table'); */

var catItemGR = new GlideRecord('sc_cat_item');

catItemGR.addActiveQuery();

catItemGR.addNotNullQuery('short_description');

catItemGR.setLimit(5);

catItemGR.query();

data.catItemList = [];

while(catItemGR.next()) {

var n = {};

$sp.getRecordValues(n, catItemGR, 'sys_id,name');

data.catItemList.push($sp.getCatalogItem(catItemGR.sys_id));

}

gs.log(input,'ss_init');

console.log(input.selectedCatItem);

if(input.selectedCatItem!=undefined){

console.log("FOUND");

data.curCatItem = $sp.getCatalogItem(input.selectedCatItem);

}

})();

input returns undefined in the syslog every time the select option changes value.

1 ACCEPTED SOLUTION

Rushit Patel2
Tera Guru

not sure if it would make any difference but try to move line 17 to 20 to top of the server script.



it shouldnt make any difference but i have seen some wierd behavior.



(please mark helpful/like/correct if it helps)


View solution in original post

8 REPLIES 8

About to flip an actual table over here. The script works in 3 other instances but my work one. But moving the input check before the rest of the script works because...


...


...



up is down, before is after...


chill mate..its service portal..its incomplete without encountering few bugs



didnt get this part "


...


...



up is down, before is after...


"



if your thing is working can you please mark answer as correct and we can close this thread.



(please mark helpful/like/correct if it helps)


just my frustration at the lack of logic and consistency lol. thank you for your help


So does it mean, it(up/down) needs to be changed again when you move to Jakarta? Strange! I have been wondering myself. Your original code works on both my work(Helsinki) and personal instances(Jakarta).



Thanks



Best,


Rama