I have custom record created in netsuite's backend named Webstore Landing Data. Record is having below structure & columns
Record Id: customrecord_webstore_category_landing
Coloumns:
i. custrecord_collection_name
ii. custrecord_collection_sub_category
iii. custrecord_collection_url
And need to create service to fetch this record on backbone view. Help appreciated.
Ok, Good question. This is the most important and required thing in SCA check below details-->
Note: Below steps is for SuiteCOmmerce Advance Vision(2016-17) release
You need to created below things-->
i. SuiteScript Model
ii. SuiteScript Service
iii.JavaScript Model
iv. JavaScript view
v. JavaScript Template
vi. Update distro.json
Create custom folder(our custom module) under custom folder as
Modules/custom/Categorylanding@1.0.0
Create SuiteScript folder under above module
Create SuiteScript Service under 'SuiteScript' Folder as below-->
FileName & Path: Modules/custom/Categorylanding@1.0.0/SuiteScript/Categorylanding.ServiceController.js
Code:
define(
'Categorylanding.ServiceController'
, [
'ServiceController'
, 'Categorylanding.Model'
]
, function(
ServiceController
, Categorylanding
)
{
'use strict';
return ServiceController.extend({
name: 'Categorylanding.ServiceController'
, get: function()
{
return Categorylanding.get();
}
});
}
);
FileName & Path: Modules/custom/Categorylanding@1.0.0/SuiteScript/Categorylanding.Model.js
Code:
define('Categorylanding.Model',
[
'SC.Model'
],
function (SCModel) {
return SCModel.extend({
name: 'Categorylanding',
get: function()
{
var filters = new Array();
var columns = new Array();
columns[0] = new nlobjSearchColumn('custrecord_collection_name');
columns[2] = new nlobjSearchColumn('custrecord_collection_url');
var results = nlapiSearchRecord('customrecord_webstore_category_landing', null, filters, columns);
var results_ = JSON.stringify(results);
return results_;
}
});
}
)
Filename & Path:
Modules/custom/Categorylanding@1.0.0/ns.package.json
Code:
{
"gulp": {
"javascript": [
"JavaScript/*"
],
"ssp-libraries": [
"SuiteScript/*.js"
],
"autogenerated-services": {
"Categorylanding.Service.ss": "Categorylanding.ServiceController"
},
"templates": [
"Templates/*"
],
"images": [
"Images/*"
],
"sass": [
"Sass/*.scss"
],
"configuration": [
"Configuration/*.json"
]
}
}
add your module under modules section as
"custom/Categorylanding": "1.0.0",
and dependencies in
"ssp-libraries": {
"entryPoint": "SCA",
"dependencies": [
"CategoryLanguage.ServiceController",
"CategoryLanguage.Model",
],
Deploy your code and once this is done you can able to see your data when in return call, you can call your service as below
http://yoursite.com/sca-dev-vinson/services/Categorylanding.Service.ss?c=4515330
Now the remaining part is how you can get this data on backbone view, to do this go to your view where you want this data
Before that create Javascript model under Same folder as below
Filename & Path :
Modules/custom/Categorylanding@1.0.0/JavaScript/Categorylanding.Model.js
Code:
define('Categorylanding.Model',
[
'Backbone',
'underscore'
],
function (Backbone, _) {
return Backbone.Model.extend(
{
url: function()
{ var urlRoot = _.getAbsoluteUrl('services/Categorylanding.Service.ss');
return urlRoot;
}
});
}
);
Define mode and use below code
var collection = new CategorylandingModel();
var view = new BrowseView({
translator: translator
, translatorConfig: self.translatorConfig
, application: self.application
, collection: collection
});
collection.fetch().done(function(data) //again fetch Instagram service
{
console.log(data) //your service data will log here
});
var recorddata = this.collection.attributes;
console.log(recorddata);
and Pass it handlebar. That's it.
Let me know if you want any help....