Hello everyone, I was just wondering if anyone has...
# suitecommerce
t
Hello everyone, I was just wondering if anyone has encountered an issue where the auto-generated Service.ss file is returning the error: TypeError: Cannot call method "handle" of undefined (apieModule.Service.ss$1071372#7). My service controller file is extending ServiceController and currently just returns a string within the GET method (just for testing). ServiceController:
Copy code
define(
	'AJG.apie192.apieModule.ServiceController'
,	[
		'ServiceController', 'ApieBackend.Model'
	]
,	function(
		ServiceController, ApieBackendModel
	)
	{
		'use strict';

		return ServiceController.extend({

			name: 'AJG.apie192.apieModule.ServiceController'

			// The values in this object are the validation needed for the current service.
		,	options: {
				common: {
				}
			}

		,	get: function get()
			{
				var abmr = ApieBackendModel.setApiePaymentMethod()
				return 'Hello Service! ' + abmr;
			}
Service.ss:
Copy code
function service(request, response)
{
	'use strict';
	try 
	{
		require('AJG.apie192.apieModule.ServiceController').handle(request, response);
	} 
	catch(ex)
	{
		console.log('AJG.apie192.apieModule.ServiceController ', ex);
		var controller = require('ServiceController');
		controller.response = response;
		controller.request = request;
		controller.sendError(ex);
	}
}
Calling function in View:
Copy code
var service_url = Utils.getAbsoluteUrl(getExtensionAssetsPath('services/apieModule.Service.ss'));

$.get(service_url).done(function(result){
	console.log('GET RESULT', result);
}).fail(function(e){
	console.log('GET FAIL', e);
});
UPDATE: I attempted to recreate the ServiceController function myself and store it with the other suitescript files of my extension (which didn't work out) but when I reverted my code to using the default ServiceController I started receiving the error: The TAX_OVERHAULING feature is not available to your company, with an error code of 400.
s
Have you deployed and activated the SuiteScript? Does your service controller appear in the ssp_libraries or ssp_libraries_ext file?
t
Hi @Steve Goldberg, Yes to both questions, my service controller appears in the ssp_libraries_ext file.
a
Hi @Steve Goldberg, running into the same issue.. is it worth raising a Gold Support case or is there something else we could look over? cheers
t
UPDATE: I have found the cause of the error, it seems to happen when I pass 'SC.Models.Init' and/or 'LiveOrder.Model' to my back-end entry point. When I removed them, the ServiceController executed correctly and the test string from my back-end entry point returned without error. After putting either of them back in, I got the same error again - "TypeError: Cannot call method "handle" of undefined (apieModule.Service.ss$1071372#7)" on the front-end and "The TAX_OVERHAULING feature is not available to your company." appearing in the execution log of the SSP. My back-end Entry Point (without 'SC.Models.Init' and 'LiveOrder.Model'):
Copy code
define('ApieBackend.Model'
,	['Application', 'Utils', 'SC.Model']
,	function(App, Utils, SCModel){

		'use strict';

		return SCModel.extend({
			
			name: 'ApieBackend',

			validation: {},
			
			setApiePaymentMethod: function(){
				nlapiLogExecution('DEBUG', 'setApiePaymentMethod', 'STARTED');
				return 'COMPLETE - APIE RETURNED';
			}
		});
	}
);