
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 05:45 AM
Hi everyone,
I'm having an issue with a creation of a widget in Service Portal.
It is throwing an error, "c is not defined", and when visualizing the code in the editor, in the first line, the declaration of the function is showing "Unexpected token (".
This was not an issue in previous ServiceNow releases.
Client controller
function ($scope, spUtil, $uibModal) {
spUtil.recordWatch($scope, $scope.data.table, "sys_id=" + $scope.data.sys_id);
/* widget controller */
var modalInstance;
var c = this;
c.uiAction = function(action) {
c.data.action = action;
c.server.update().then(function() {
c.data.action = undefined;
})
};
$scope.$on('record.updated', function(name, data) {
//c.data.reopenComments = '';
spUtil.update($scope);
modalInstance.dismiss();
});
c.openModalSignature = function() {
modalInstance = $uibModal.open({
templateUrl: 'modalTemplateSignature.html',
scope: $scope
});
};
}
Has anything changed in this release in regards to AngularJS and in the way we should declare the client controller?
If anyone helps me I would much appreciate it 🙂
Regards
Hugo Gomes
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 07:13 AM
So some thoughts on troubleshooting. Comment out all of the code in the function(s) and see if the issue goes away. If not keep commenting things out until it does. That should tell you where. If commenting out the code in a function causes it to go away start uncommenting them one line at a time until it comes back. That should give you something to look at.
But if you look at the error it says "Server JavaScript error "c" is not defined." It looks to me you posted the client side code not the server code. In my experience c is not declared in the server code only client side.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 07:13 AM
So some thoughts on troubleshooting. Comment out all of the code in the function(s) and see if the issue goes away. If not keep commenting things out until it does. That should tell you where. If commenting out the code in a function causes it to go away start uncommenting them one line at a time until it comes back. That should give you something to look at.
But if you look at the error it says "Server JavaScript error "c" is not defined." It looks to me you posted the client side code not the server code. In my experience c is not declared in the server code only client side.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 09:45 AM
The issue was on the Server Script.
Thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2020 07:40 AM
What did you change in the server script to get rid of the error?