Getting a "Parsing error: Unexpected token (" error in Widget Client Controller
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 01:45 PM
Hi,
I've been over this code many times but cannot find the syntax error which is causing the "Parsing error: Unexpected token (" error on the first line of code. Any help is appreciated. This is the code:
function ($scope, $location, $rootScope, spUtil, $interpolate) {
var c = this;
this.data.filterText = "";
this.showFilter = false;
this.onClick = function($event, item, url, action) {
$event.stopPropagation();
$event.preventDefault();
if (typeof url == "string") {
var urlExp = $interpolate(url);
url = urlExp(item);
$location.url(url);
} else if (url && typeof url == "object")
$location.search(url);
else {
var evt = {};
evt.url = url;
evt.table = item.className;
evt.sys_id = item.sys_id;
evt.record = item;
evt.rectangle_id = c.options.sys_id;
evt.action = action;
// put out the selection with simple list "sl_" prefix
$location.search('sl_sys_id', evt.sys_id);
$location.search('sl_table', evt.table);
$location.search('spa', 1); // spa means "I've got this"
$rootScope.$broadcast('$sp.list.click', evt);
}
};
if (c.options.table && c.options.disable_record_watcher != 'true')
spUtil.recordWatch($scope, c.options.table, c.options.filter);
this.getMaxShownLabel = function(maxEntries, totalCount) {
if (totalCount == c.data.maxCount)
return "${First [0] of more than [1]}".replace('[0]', maxEntries).replace('[1]', totalCount);
return "${First [0] of [1]}".replace('[0]', maxEntries).replace('[1]', totalCount);
};
this.seeAllPage = c.options.list_page_dv || 'list';
this.targetPageID = (c.options.sp_page) ? "&target_page_id=" + c.options.sp_page : "";
c.getMaxHeight = function() {
return c.options.panel_body_height || 'none';
};
c.getActionColor = function(action) {
return "text-" + action.color;
};
c.update = function update() {
c.server.update();
}
c.toggleFilter = function() {
c.showFilter = !c.showFilter;
}
function get() {
spUtil.update($scope);
}
// pagination
$scope.previousPage = function() {
if ($scope.data.pagination.currentPage > 1)
$scope.data.pagination.currentPage = $scope.data.pagination.currentPage - 1;
else
$scope.data.pagination.currentPage = 0;
get();
}
$scope.nextPage = function() {
$scope.data.pagination.currentPage = $scope.data.pagination.currentPage+1;
get();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2023 11:01 AM
Please post the full widget, and please use the "Insert / Edit code sample" functionality to post code.
The code you have posted so far is only the client controller which is looking ok.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 10:51 PM
Hello,
did you find answer for this?
I'm also getting the same issue.
regards
Gaurav Vaze
ServiceNow Developer