ErrorServer JavaScript error Method "toString" called on incompatible object.

raja_5
Tera Expert

Hi Experts,

 

I have cloned OOTB widget : Knowledge Bases Browse

im getting error :  ErrorServer JavaScript error Method "toString" called on incompatible object.

in line number 2 of below script, Please suggest,

 

var kbService = new global.CopyKBPortalService();
        options.knowledge_bases = options.knowledge_bases || String(kbService.getServicePortalKnowledgeBases($sp.getPortalRecord().url_suffix)) || "";
        data.isMobile = kbService.isMobile();
        data.result = kbService.getMyKnowledgeBases(options.order_by,options.knowledge_bases);
        var kbCount = data.result.length;
        var articleCount = 0;
        var socailqaCount = 0;

 

1 ACCEPTED SOLUTION

raja_5
Tera Expert
calling KBPortalServiceImpl script include in CopyKBPortalService instead of CopyKBPortalServiceImpl resolved the issue

View solution in original post

9 REPLIES 9

@raja_5 

did you debug what came as return value of that function?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

when i try the function, it throws an error "unterminated string literal"

@raja_5 

did you add gs.info() and check what came in logs?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

ChrisBurks
Mega Sage

It also looks like a copy of the KBPortalService script include is copied as well; line 1 in the script you posted.

The error suggests that the method ".toString()" is being called which does not seem to be within the posted script.
This leads me to believe that the error may be somewhere inside the "CopyKBPortalService" as this would also point to line 2 if there is an error there because it's being used on line 2.

raja_5
Tera Expert
calling KBPortalServiceImpl script include in CopyKBPortalService instead of CopyKBPortalServiceImpl resolved the issue