Hi there, I'm working on a SCA extension for 2019....
# suitecommerce
h
Hi there, I'm working on a SCA extension for 2019.2 that re-maps the Store Locator to pull information from another record. Rather than re-inventing the wheel and replacing everything that is already there, I would love to extend the existing SuiteScript functions that retrieve the locations to instead look elsewhere. Then that data can flow up to the front end of SCA and everything else can stay the same. My issue is that my attempts to use
_.extend()
in an extension on a SuiteScript file appears to have no effect of being able to override the core function. Has anyone had any success extending/overriding core SuiteScript functions via an extension - how did you get yours working?
p
can you paste a code sample?
h
Copy code
_.extend(LocationModel, {
		list: _.wrap(LocationModel.list, function list(fn)
		{
			var data = fn.apply(this, _.toArray(arguments).slice(1)) || {};

			nlapiLogExecution('DEBUG', 'testing override', JSON.stringify(data));

			return data;
		})
    });
If I run a log outside of this function it executes, but the log within does not execute when I trigger the list function of the LocationModel.
p
Could it be that you are extending Location.Model but you're actually in the need of
Copy code
'StoreLocator.Model'
?
👍🏻 2
h
Oh gosh! I think that'll be it 🤦‍♂️ Let me run a quick deployment!
@PabloZ thanks! That was it exactly!
😎 1
b
I have customized StoreLocator Location records to custom records but not in an extension. If you want to hav a look at the site links: https://www.frogbikes.co.uk/stores https://www.frogbikes.co.uk/events