Service Portal consoleError

kailashthiyagar
Kilo Guru

I m getting this error in the console while trying to access the catalog item in the service portal. This occurs in PRD environment but works fine in stage/TEST/Dev

amb.MessageClient [INFO] >>> connection exists, request satisfied

js_includes_sp.jsx?v=02-24-2017_1059&lp=Fri_Oct_06_20_23_58_PDT_2017&c=33_354:11973 TypeError: Cannot read property 'description' of undefined

This is the line

$scope.data.sc_cat_item.description = $sce.trustAsHtml($scope.data.sc_cat_item.description);

16 REPLIES 16

By default if i access the /sp_config?id=sc_cat_item, i m getting this error



DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337


File: sp_config


HTML1300: Navigation occurred.


File: sp_config


HTML1504: Unexpected end tag.


File: sp_config, Line: 1, Column: 299


HTML1504: Unexpected end tag.


File: sp_config, Line: 1, Column: 413


HTML1504: Unexpected end tag.


File: sp_config, Line: 1, Column: 476


HTML1504: Unexpected end tag.


File: sp_config, Line: 1, Column: 533


HTML1504: Unexpected end tag.


File: sp_config, Line: 1, Column: 592


DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337


File: sp_config


amb.MessageClient [INFO] >>> connection exists, request satisfied


TypeError: Unable to get property 'description' of undefined or null reference


    at api.controller (eval code:5:2)


    at invoke (https://optumdev2.service-now.com/scripts/js_includes_sp.jsx?v=02-24-2017_1059&lp=Fri_Oct_06_20_23_5...)


    at $controllerInit (https://optumdev2.service-now.com/scripts/js_includes_sp.jsx?v=02-24-2017_1059&lp=Fri_Oct_06_20_23_5...)


    at nodeLinkFn (https://optumdev2.service-now.com/scripts/js_includes_sp.jsx?v=02-24-2017_1059&lp=Fri_Oct_06_20_23_5...)


    at compositeLinkFn (https://optumdev2.service-now.com/scripts/js_includes_sp.jsx?v=02-24-2017_1059&lp=Fri_Oct_06_20_23_5...)


    at publicLinkFn (https://optumdev2.service-now.com/scripts/js_includes_sp.jsx?v=02-24-2017_1059&lp=Fri_Oct_06_20_23_5...)


    at render (https://optumdev2.service-now.com/scripts/js_includes_sp.jsx?v=02-24-2017_1059&lp=Fri_Oct_06_20_23_5...)


    at load (https://optum


And if you comment below line, you dont see this issue?



$scope.data.sc_cat_item.description = $sce.trustAsHtml($scope.data.sc_cat_item.description);



Please mark this response as correct or helpful if it assisted you with your question.

when i do preview of my widget, its not appearing.. do u think its something with scope or access r some configuration change?


I wish you could have reproduced it on Non-Prod environment and it would have been easier. I remember using trustAsHtml and it had some problem so I had to remove it. I think it was not refreshing if I change the content. In your case, I have a feeling the description is either coming blank or $scope issue.



In server script, try storing it in a different variable. like data.description = data.sc_cat_item.description;



And in Client Controler script use


$scope.data.description = $sce.trustAsHtml($scope.data.description);



Also in HTML change


  1.               <div ng-if="::data.description" class="wrapper-md b-t">  
  2.                   <div ng-bind-html="::data.description"></div>  


The other option is not use trustAsHtml. Just show the data as it is in description.



Please mark this response as correct or helpful if it assisted you with your question.

Bharat23
Kilo Guru

Did you figure out the root cause or solution. I am also facing something similar.