最终将一个套件链接到另一个套件。
我创建了一个表单,该表单返回带有复选框的子列表。但是无法使用添加的字段(用于过滤器)和复选框(提交和转换)进行操作。
The form has added Fields and the already filtered sublist at the bottom.
How would I do the following:
1. Add additional filters after clicking the Filter Button?
[which is similar to the code :
var trandate = '&trandate='+nlapiGetFieldValue('custpage_trandate'); ]
2. Transform the selected checked transactions after clicking the Submit Button?
表单具有addField,页面和子列表。
它与下面的链接非常相似,但是由于它是用Suitescript 1.0和2.0版本编写的,因此我无法理解它,因为该示例返回了一个错误:https://netsuite.custhelp.com/app/answers/detail/a_id/89356/kw/form%20filter%20suitescript%202
编辑:我已经添加了代码,以更详细地说明我所拥有的和想要做的] Suitelet代码 * @NApiVersion 2.x
* @NScriptType Suitelet
*/
var PAGE_SIZE = 20;
var SEARCH_ID = 'customsearch1160';
var CLIENT_SCRIPT_FILE_ID = 9836;
define(['N/ui/serverWidget', 'N/search', 'N/redirect'],
function (serverWidget, search, redirect) {
function onRequest(context) {
if (context.request.method == 'GET') {
var form = serverWidget.createForm({
title : 'Unbilled Orders',
hideNavBar : false
});
form.clientScriptFileId = CLIENT_SCRIPT_FILE_ID;
form.addField({
id: 'trandate_criteria',
type: serverWidget.FieldType.DATE,
label: 'Transaction Date',
source: 'trandate'
});
var customer_field = form.addField({
id : 'name_criteria',
label : 'Name',
type : serverWidget.FieldType.MULTISELECT,
source: 'customer'
});
// form.addField({
// id : 'orderno_criteria',
// label : 'Document No.',
// type : serverWidget.FieldType.MULTISELECT,
// source: 'transaction'
// });
form.addField({
id : 'orderno_criteria',
label : 'Document No.',
type : serverWidget.FieldType.MULTISELECT,
source: 'transaction'
});
form.addField({
id : 'location_criteria',
label : 'Location',
type : serverWidget.FieldType.MULTISELECT,
source: 'location'
});
var statusA = form.addField({
id : 'status_criteria',
label : 'Status',
type : serverWidget.FieldType.MULTISELECT,
source: 'status'
});
statusA.addSelectOption({
value :'Pending Billing', text :'Pending Billing'});
statusA.addSelectOption({
value :'Pending Billing/Partially Fulfilled', text :'Pending Billing/Partially Fulfilled'});
var buttonSubmit = form.addSubmitButton({
label: 'Submit'
});
var buttonFilter = sublist.addButton({
label: 'Filter',
id: 'custpage_mybutton',
functionName: 'myButtonFunction'
});
// Get parameters
var pageId = parseInt(context.request.parameters.page);
var scriptId = context.request.parameters.script;
var deploymentId = context.request.parameters.deploy;
// Add sublist that will show results
var sublist = form.addSublist({
id : 'custpage_table',
type : serverWidget.SublistType.LIST,
label : 'Orders to Bill'
});
sublist.addMarkAllButtons();
sublist.addRefreshButton();
sublist.addField({
id : 'custpage_id',
label : 'Check',
type : serverWidget.FieldType.CHECKBOX
}).updateDisplayType({displayType: serverWidget.FieldDisplayType.ENTRY});
// Add columns to be shown on Page
sublist.addField({
id : 'id',
label : 'Internal ID',
type : serverWidget.FieldType.TEXT
});
// sublist.addField({
// id : 'amount',
// label : 'Amount',
// type : serverWidget.FieldType.CURRENCY
// });
sublist.addField({
id: 'tran_id',
type: serverWidget.FieldType.TEXT,
label: 'Document No.'
});
sublist.addField({
id: 'trandate_id',
type: serverWidget.FieldType.TEXT,
label: 'Transaction Date'
});
sublist.addField({
id : 'name_id',
label : 'Name',
type : serverWidget.FieldType.TEXT
});
sublist.addField({
id : 'location_id',
label : 'Location',
type : serverWidget.FieldType.TEXT
});
sublist.addField({
id : 'amount_id',
label : 'Amount',
type : serverWidget.FieldType.CURRENCY
});
sublist.addField({
id : 'status_id',
label : 'Status',
type : serverWidget.FieldType.TEXT
});
// Run search and determine page count
var retrieveSearch = runSearch(SEARCH_ID, PAGE_SIZE);
var pageCount = Math.ceil(retrieveSearch.count / PAGE_SIZE);
// Set pageId to correct value if out of index
if (!pageId || pageId == '' || pageId < 0)
pageId = 0;
else if (pageId >= pageCount)
pageId = pageCount - 1;
// Add buttons to simulate Next & Previous
if (pageId != 0) {
form.addButton({
id : 'custpage_previous',
label : 'Previous',
functionName : 'getSuiteletPage(' + scriptId + ', ' + deploymentId + ', ' + (pageId - 1) + ')'
});
}
if (pageId != pageCount - 1) {
form.addButton({
id : 'custpage_next',
label : 'Next',
functionName : 'getSuiteletPage(' + scriptId + ', ' + deploymentId + ', ' + (pageId + 1) + ')'
});
}
// Add drop-down and options to navigate to specific page
var selectOptions = form.addField({
id : 'custpage_pageid',
label : 'Page Index',
type : serverWidget.FieldType.SELECT
});
for (i = 0; i < pageCount; i++) {
if (i == pageId) {
selectOptions.addSelectOption({
value : 'pageid_' + i,
text : ((i * PAGE_SIZE) + 1) + ' - ' + ((i + 1) * PAGE_SIZE),
isSelected : true
});
} else {
selectOptions.addSelectOption({
value : 'pageid_' + i,
text : ((i * PAGE_SIZE) + 1) + ' - ' + ((i + 1) * PAGE_SIZE)
});
}
}
// Get subset of data to be shown on page
var addResults = fetchSearchResult(retrieveSearch, pageId);
// Set data returned to columns
var j = 0;
addResults.forEach(function (result) {
sublist.setSublistValue({
id : 'id',
line : j,
value : result.id
});
// sublist.setSublistValue({
// id : 'amount',
// line : j,
// value : result.amount
// });
//SET VALUES
sublist.setSublistValue({
id : 'tran_id',
line : j,
value : result.tran_id
});
sublist.setSublistValue({
id : 'trandate_id',
line : j,
value : result.trandate_id
});
sublist.setSublistValue({
id : 'name_id',
line : j,
value : result.name_id
});
sublist.setSublistValue({
id : 'location_id',
line : j,
value : result.location_id
});
sublist.setSublistValue({
id : 'amount_id',
line : j,
value : result.amount_id
});
sublist.setSublistValue({
id : 'status_id',
line : j,
value : result.status_id
});
j++;
});
context.response.writePage(form);
}
if (context.request.method == 'POST') {//POST
//Get Select Field Value
var delimiter = /\u0005/;
var id_filter =context.request.parameters.id.split(delimiter);
var date_filter =context.request.parameters.trandate_criteria.split(delimiter);
var name_filter =context.request.parameters.name_field.split(delimiter);
var orderNo_filter =context.request.parameters.orderno_criteria.split(delimiter);
var location_filter =context.request.parameters.location_criteria.split(delimiter);
var status_filter =context.request.parameters.status_criteria.split(delimiter);
log.debug("tranid", orderNo);
}
return {
onRequest : onRequest
};
function runSearch(searchId, searchPageSize) {
var searchObj = search.load({
id : searchId
});
log.debug('searchObj', JSON.stringify(searchObj));
return searchObj.runPaged({
pageSize : searchPageSize
});
}
function fetchSearchResult(pagedData, pageIndex) {
var searchPage = pagedData.fetch({
index : pageIndex
});
var results = new Array();
searchPage.data.forEach(function (result) {
var internalId = result.id;
var tran_id = result.getValue({name: 'tranid'});
var trandate_id = result.getValue({name: 'trandate'});
var name_id = result.getText({name: 'entity'});
var location_id = result.getText({name: 'location'});
var amount_id = result.getValue({name: 'amount'});
var status_id = result.getText({name: 'statusref'});
results.push({
"id" : internalId,
"tran_id" : tran_id,
"trandate_id" : trandate_id,
"name_id" : name_id,
"location_id" : location_id,
"amount_id" : amount_id,
"status_id" : status_id
});
});
return results;
}
});
ClientScript:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define(['N/url'],
function (url) {
function fieldChanged(context) {
// Navigate to selected page
if (context.fieldId == 'custpage_pageid') {
var pageId = context.currentRecord.getValue({
fieldId : 'custpage_pageid'
});
pageId = parseInt(pageId.split('_')[1]);
document.location = url.resolveScript({
scriptId : getParameterFromURL('script'),
deploymentId : getParameterFromURL('deploy'),
params : {
'page' : pageId
}
});
}
}
function getSuiteletPage(suiteletScriptId, suiteletDeploymentId, pageId) {
document.location = url.resolveScript({
scriptId : suiteletScriptId,
deploymentId : suiteletDeploymentId,
params : {
'page' : pageId
}
});
}
function getParameterFromURL(param) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == param) {
return decodeURIComponent(pair[1]);
}
}
return (false);
}
return {
fieldChanged : fieldChanged,
getSuiteletPage : getSuiteletPage
};
});
我创建了一个表单,该表单返回带有复选框的子列表。但是无法使用添加的字段(用于过滤器)和复选框(提交和转换)进行操作。表单添加了字段和...
最终将一个套件链接到另一个套件。
最终将一个套件链接到另一个套件。