我在netsuite的后端创建了自定义记录,名为Webstore Landing Data。记录具有以下结构&列
Record Id: customrecord_webstore_category_landing
Coloumns:
i. custrecord_collection_name
ii. custrecord_collection_sub_category
iii. custrecord_collection_url
需要创建服务以在骨干视图上获取此记录。帮助赞赏。
答案 0 :(得分:3)
好的,好问题。这是SCA中最重要和最需要的东西,请查看以下详细信息 - >
注意:以下步骤适用于SuiteCOmmerce Advance Vision(2016-17)发布
您需要创建以下内容 - >
i. SuiteScript Model
ii. SuiteScript Service
iii.JavaScript Model
iv. JavaScript view
v. JavaScript Template
vi. Update distro.json
在自定义文件夹下创建自定义文件夹(我们的自定义模块)
Modules/custom/Categorylanding@1.0.0
在上面的模块下创建SuiteScript文件夹
在'SuiteScript'文件夹下创建SuiteScript服务,如下所示 - >
FileName&路径: Modules/custom/Categorylanding@1.0.0/SuiteScript/Categorylanding.ServiceController.js
代码:
define(
'Categorylanding.ServiceController'
, [
'ServiceController'
, 'Categorylanding.Model'
]
, function(
ServiceController
, Categorylanding
)
{
'use strict';
return ServiceController.extend({
name: 'Categorylanding.ServiceController'
, get: function()
{
return Categorylanding.get();
}
});
}
);
FileName&路径:强> Modules/custom/Categorylanding@1.0.0/SuiteScript/Categorylanding.Model.js
<强>代码:强>
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_;
}
});
}
)
文件名&amp;路径:强>
Modules/custom/Categorylanding@1.0.0/ns.package.json
<强>代码:强>
{
"gulp": {
"javascript": [
"JavaScript/*"
],
"ssp-libraries": [
"SuiteScript/*.js"
],
"autogenerated-services": {
"Categorylanding.Service.ss": "Categorylanding.ServiceController"
},
"templates": [
"Templates/*"
],
"images": [
"Images/*"
],
"sass": [
"Sass/*.scss"
],
"configuration": [
"Configuration/*.json"
]
}
}
将模块添加到模块部分
"custom/Categorylanding": "1.0.0",
和
中的依赖项"ssp-libraries": {
"entryPoint": "SCA",
"dependencies": [
"CategoryLanguage.ServiceController",
"CategoryLanguage.Model",
],
部署您的代码,一旦完成,您就可以在回电话中查看您的数据,您可以按以下方式拨打您的服务
http://yoursite.com/sca-dev-vinson/services/Categorylanding.Service.ss?c=4515330
现在剩下的部分是如何在骨干网视图上获取这些数据,为此,请转到您想要此数据的视图
之前在相同的文件夹下创建Javascript模型
文件名&amp;路径:
Modules/custom/Categorylanding@1.0.0/JavaScript/Categorylanding.Model.js
<强>代码:强>
define('Categorylanding.Model',
[
'Backbone',
'underscore'
],
function (Backbone, _) {
return Backbone.Model.extend(
{
url: function()
{ var urlRoot = _.getAbsoluteUrl('services/Categorylanding.Service.ss');
return urlRoot;
}
});
}
);
定义模式并使用下面的代码
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);
并传递车把。就是这样。
如果您需要任何帮助,请告诉我。