关于netsuite创建组合按钮的方法,合并按钮,netsuite API-CarlZeng

组合按钮就是netsuite中比较常用的控件,就是系统自动的将相类型功能的按钮拼接在一起,在系统的设置首选项(/app/center/userprefs.nl?sc=-29)中可以控制是否使用组合按钮。合并表格中的类似按钮Check this box to roll up similar buttons on forms.For example, checking this box rolls u…

组合按钮就是netsuite中比较常用的控件,就是系统自动的将相类型功能的按钮拼接在一起,在系统的设置首选项(/app/center/userprefs.nl?sc=-29)中可以控制是否使用组合按钮。

合并表格中的类似按钮 “这是什么?”)

Check this box to roll up similar buttons on forms.

For example, checking this box rolls up all save options under the Save button. Click the arrow on the Save button to see a list of options and choose how you want to save the form.

字段ID: COMBINESIMILARBUTTONS

系统内置的api,不包含在发布的guide中。隐含API。

一下是以export按钮为例子来说明的按钮合并:

[[‘Export – CSV’, “export”],[‘Export – Microsoft ® Excel’, “exportXLS”]] 这是两个按钮,

‘Export – CSV’,’null’,’export’ 这个是默认的按钮显示,和它的ID系统既能关联出其方法来,具体方法我会单独写出来。

[‘Export – CSV’, “export”] 是一个按钮以及点击后的方法名。

![](D:imagesnavstretch.gif)

![](D:imagesnavstretch.gif)

如何[http://www.cnblogs.com/backuper/archive/2008/12/08/1350230.html](http://www.cnblogs.com/backuper/archive/2008/12/08/1350230.html)

# [JS导出txt文本文件,Netsuite方案](http://www.cnblogs.com/backuper/archive/2008/12/08/1350230.html)

document.location.replace(appendFormDataToURL(‘/app/crm/support/caselist.xls?searchtype=Case’));

上一篇内容中写到的导出txt,完全可以通过这个方法,通过suitelet自动的生成txt然后就可以弹出txt保存的窗口,提供用户下载。

这样两篇文章结合起来即可写出比较完美导出方案。利用系统隐含的API哦~~

netsuite技术客服已经建议过我,尽量少用这类的系统未公布的API,

因为netsuite完全可以不通知你的情况替换掉这个api这样你以前写的程序就应声倒下, 不好,不好~ 呵呵,,

关于NetSuite内部Enhancement发表及查看的实现(netsuite论坛,netsuite留言本,netsuite评论的实现)-CarlZeng

在system的 Enhancement Voting > Search Results > Enhancement Voting 中,我们能看到Netsuite是如何实现一个系统的评论功能,个人分析如下: 1.在Netsuite总账户中,主站点的’标签’中建立New Release Info 和 Enhancement Voting的标签,配置相应的权限,2.建立记录类型,大致字段内容如下:…

在system的  Enhancement Voting > Search Results >
Enhancement Voting 中,我们能看到Netsuite是如何实现一个系统的评论功能,
个人分析如下:

1.在Netsuite总账户中,主站点的’标签’中建立New Release Info  和 Enhancement Voting的标签,配置相应的权限,
2.建立记录类型,大致字段内容如下:
Enh No.

Product Area

Abstract

Status

Release Target

Your Rating

Click To Vote

View Comments

Total Votes

3.发布一个特定的搜索到Enhancement Voting标签下,(或者我猜测更像一个suitelet)
功能包括:搜索、提交选举(Vote)和查看用户评论(View  Comment).

这里我主要讲一下这个提交选举结果(vote)和View  Comment的实现:

4.  vote: 我们可以看到https://debugger.netsuite.com/app/site/hosting/scriptlet.nl?script=customscript_enh_vote_suitelet&deploy=customdeploy_enh_vote_suitelet&l=T&issue=844925

一看ok , this is a suitelet, named(internalId):customscript_enh_vote_suitelet
and has been deploy to be:customdeploy_enh_vote_suitelet.
我们来看这个suitelet还有两个参数。l 和issue; l猜测是列表方式,issue就是netsuite内部issue的编号。

在customscript_enh_vote_suitelet这个suitelet中,issue显然被当作一个参数来保存到这个特定的记录类型,以便用户内部标示和关联。
功能描述:suitelet create some field  for description. a TEXTAREA and a speciel control for input level.(用来浏览和界定用户关心程度);submit后系统保存这条记录到这个特定的记录类型,并且更新Total Votes数量等信息。

5。也就是查看评论功能:https://debugger.netsuite.com/app/site/hosting/scriptlet.nl?script=customscript_enh_vote_seevotes&deploy=customdeploy_enh_vote_seevotes&l=T&issue=844925
   我们可以得出这个也是一个suitelet,internalId:customscript_enh_vote_seevotes;deploy:customdeploy_enh_vote_seevotes
同样具备l参数和issue参数传递进来用来判断这个view comment能浏览到的内容列表。

功能描述:suitelet根据参数搜索得出searchresult.根据searchresult功能生成 HTML的内容页面,和一个close按钮(window.close)。

这样一个内部的评论系统就实现了。
以上是一些个人思路,希望对您有点帮助。author:zeng.cz 200811192232
Today is my girlfriend’s birthday. write this ,wish her Happy Birthday!

to display netsuite transactions detail-CarlZeng

&xml=T https://system.netsuite.com/app/accounting/transactions/transaction.nl?id=3179&e=T use &xml=T below to display xml 用于排除故障用的测试地址, 把xml输出 既可查询一些数值情况,优先于UI的动作。 zeng.cz 20090421 1508

&xml=T

https://system.netsuite.com/app/accounting/transactions/transaction.nl?id=3179&e=T use &xml=T below to display xml

用于排除故障用的测试地址, 把xml输出 既可查询一些数值情况,优先于UI的动作。

zeng.cz
20090421 1508

totemsuite与Netsuite OneWorld-CarlZeng

NetSuite OneWorld产品代理: 图腾盛视(北京)科技有限公司(TotemSute)是美国NetSuite公司在中国唯一的战略合作伙伴。美国NetSuiteInc.在中国地区的首家增值解决方案供应商。图腾盛视(北京)科技有限公司座落于北京市朝阳区建国路华贸商务中心。办公场地有600余平。管理团队由优秀的互联网技术、运营人员和有多年传统行业成功…

NetSuite OneWorld产品代理:
图腾盛视北京)科技有限公司(TotemSute)是美国NetSuite公司在中国唯一的战略合作伙伴。美国NetSuiteInc.在中国地区的首家增值解决方案供应商。图腾盛视(北 京)科技有限公司座落于北京市朝阳区建国路华贸商务中心。办公场地有600余平。管理团队由优秀的互联网技术、运营人员和有多年传统行业成功商务经验的人 员组成。我公司致力于将国际化的先进的管理理念和先进的信息技术相融合,尽最大努力满足本地用户的业务需求,为客户创造更多价值。

跨国公司在全世界范围内运行一个系统

NetSuite OneWorld允许企业实时管理他们的跨国公司或多个子公司的经营活动

NetSuite OneWorld 是首个为中型企业提供全球业务管理和财务合并功能的按需定制系统。利用NetSuite OneWorld,您可以通过一个系统管理多个子公司、商业部门等,方便快捷地处理不同的货币、税收政策和报表需求。每一个独立用户都可以用其当地语言使用软件并用当地货币作交易,税收和财政也完全符合当地法规。

实时全球商业管理

与那些只能把财务信息合并在一起的财务/ERP解决方案不同,NetSuite OneWorld 的功能远比管理财务要高级——它让您更好地管理您的整个全球商业活动。

全球 财务/ERP
实时的多币种财务合并和总计。

全球CRM
多币种配额、预测、佣金支付、计算营业税、实时报表、销售线索管理、案例发送、实时的市场营销和服务。

全球电子商务
单一系统管理多币种、多语言、多国家或多商标的网站。

全球商务智能
基于角色的仪表盘显示了地方、区域和全球范围内所有的商业活动,深入挖掘各个子公司的货币信息。

NetSuite OneWorld 主要优势:

  • 更高级的业务管理。NetSuite OneWorld 为世界范围内的管理人员和员工提供了他们能更好地管理整个业务所需的所有功能、信息和工具。
  • 即时合并。那些拥有跨国子公司或多个实体机构的企业可以提高工作效率,加强财务和操作数据的合并。
  • 实时可视性。局部地区的仪表盘和全球范围内的仪表盘在显示内容上统一,所作决策得到明显改善。
  • 前所未有的整合性和数据的高质量性。由于您全球业务都在一个软件内执行并托管到一个数据库中,因此您整个业务信息的出处只有一个,保证了资料的真实性。
  • 节省成本。NetSuite OneWorld的成本比传统ERP系统的要少得多。
  • 提高预测性。多币种、跨国预测确保销售管理万无一失。
  • 高适应性和内部可控性OneWorld遵循大多数法规,如国际财务报告准则(IFRS)和萨班斯-奥克斯利法案等。
  • 简单迅速地部署。NetSuite OneWorld的部署时间要比其他传统ERP系统少90%。

更多关于NetSuite OneWorld

数据文档:

白皮书:

特定区域的仪表盘


每个国家及用户都有一个基于用户的仪表盘
来扩展他们的需求。点击这里查看.

(today) oracle 获取当前日期 netsuite-CarlZeng

GETDATE()oracle 获取当前日期在netsuite中 设置某个date类型的数据即可以初始化其内容为当前日期。(Validation & Defaultingtab中设置) 应设置为 :{today}Define the formula ({today}-{startdate}) > 3 as a search filter to return only cases open fo…

GETDATE()
oracle 获取当前日期

在netsuite中  设置某个date类型的数据即可以初始化其内容为当前日期。(

Validation & Defaulting

tab中设置)  应设置为 :{today}

Define the formula ({today}-{startdate}) > 3 as a search filter to return only cases open for greater than 3 days.

netsuite中支持的数据库级的default value 可用的方法有:

<script>
var win = window.isOLC ? window : parent.makeDropdown ? parent : window;
var dd = win.makeDropdown(‘function’, 184, [”, ”, ‘ABS’, ‘ABS(n)’, ‘ACOS’, ‘ACOS(n)’, ‘ADD_MONTHS’, ‘ADD_MONTHS(date, integer)’, ‘ASCII’, ‘ASCII(char)’, ‘ASIN’, ‘ASIN(n)’, ‘ATAN’, ‘ATAN(n)’, ‘ATAN2’, ‘ATAN2(n1 { , | / } n2)’, ‘BITAND’, ‘BITAND(expr1, expr2)’, ‘CEIL’, ‘CEIL(n)’, ‘CHR’, ‘CHR(n [ USING NCHAR_CS ])’, ‘COALESCE’, ‘COALESCE(expr [, expr ]…)’, ‘CONCAT’, ‘CONCAT(char1, char2)’, ‘COS’, ‘COS(n)’, ‘COSH’, ‘COSH(n)’, ‘DECODE’, ‘DECODE(expr, search, result [, search, result ]…[, default ])’, ‘DENSE_RANK’, ‘DENSE_RANK(expr [, expr ]…) WITHIN GROUP (ORDER BY expr [ DESC | ASC ] [ NULLS { FIRST | LAST } ] [,expr [ DESC | ASC ] [ NULLS { FIRST | LAST } ] ]… )’, ‘EXP’, ‘EXP(n)’, ‘FLOOR’, ‘FLOOR(n)’, ‘INITCAP’, ‘INITCAP(char)’, ‘INSTR’, ‘INSTR(string , substring [, position [, occurrence ]])’, ‘KEEP’, ‘KEEP(DENSE_RANK { FIRST | LAST } ORDER BY expr [ NULLS { FIRST | LAST } ])’, ‘LAST_DAY’, ‘LAST_DAY(date)’, ‘LENGTH’, ‘LENGTH(char)’, ‘LN’, ‘LN(n)’, ‘LOG’, ‘LOG(n2, n1)’, ‘LOWER’, ‘LOWER(char)’, ‘LPAD’, ‘LPAD(expr1, n [, expr2 ])’, ‘LTRIM’, ‘LTRIM(char [, set ])’, ‘MOD’, ‘MOD(n2, n1)’, ‘MONTHS_BETWEEN’, ‘MONTHS_BETWEEN(date1, date2)’, ‘NANVL’, ‘NANVL(n2, n1)’, ‘NEXT_DAY’, ‘NEXT_DAY(date, char)’, ‘NULLIF’, ‘NULLIF(expr1, expr2)’, ‘NVL’, ‘NVL(expr1, expr2)’, ‘NVL2’, ‘NVL2(expr1, expr2, expr3)’, ‘POWER’, ‘POWER(n2, n1)’, ‘RANK’, ‘RANK(expr [, expr ]…) WITHIN GROUP (ORDER BY expr [ DESC | ASC ] [ NULLS { FIRST | LAST } ] [,expr [ DESC | ASC ] [ NULLS { FIRST | LAST } ] ]… )’, ‘REGEXP_INSTR’, ‘REGEXP_INSTR(source_char, pattern [, position [, occurrence [, return_option [, match_parameter ]]]])’, ‘REGEXP_REPLACE’, ‘REGEXP_REPLACE(source_char, pattern [, replace_string [, position [, occurrence [, match_parameter ]]]])’, ‘REGEXP_SUBSTR’, ‘REGEXP_SUBSTR(source_char, pattern [, position [, occurrence [, match_parameter ]]])’, ‘REMAINDER’, ‘REMAINDER(n2, n1)’, ‘REPLACE’, ‘REPLACE(char, search_string [, replacement_string ])’, ‘ROUND (DATE)’, ‘ROUND(date [, fmt ])’, ‘ROUND (number)’, ‘ROUND(n [, integer ])’, ‘RPAD’, ‘RPAD(expr1 , n [, expr2 ])’, ‘RTRIM’, ‘RTRIM(char [, set ])’, ‘SIGN’, ‘SIGN(n)’, ‘SIN’, ‘SIN(n)’, ‘SINH’, ‘SINH(n)’, ‘SOUNDEX’, ‘SOUNDEX(char)’, ‘SQRT’, ‘SQRT(n)’, ‘SUBSTR’, ‘SUBSTR(char, position [, substring_length ])’, ‘TAN’, ‘TAN(n)’, ‘TANH’, ‘TANH(n)’, ‘TO_CHAR()’, ‘TO_CHAR({ datetime | interval } [, fmt [, ‘nlsparam’ ] ])’, ‘TRANSLATE’, ‘TRANSLATE(expr, from_string, to_string)’, ‘TREAT’, ‘TREAT(expr AS [ REF ] [ schema. ]type)’, ‘TRIM’, ‘TRIM([ { { LEADING | TRAILING | BOTH }[ trim_character ] | trim_character} FROM ]trim_source)’, ‘TRUNC (number)’, ‘TRUNC(n1 [, n2 ])’, ‘TRUNK (DATE)’, ‘TRUNC(date [, fmt ])’, ‘UPPER’, ‘UPPER(char)’], 0, ”, ”, “setWindowChanged(window, true);setValueToFormula(this,formula);”, null, 200,document,-2147483648);
dd.setMandatoryBackgroundColor(‘FFFFE5’);
</script>

po,so等单据,读取关联的流程业务数据,netsuite-CarlZeng

刚发现一个未公布的对象,拿purchaseorder举例,就是Receipts & Bills这个subtab有于当前业务单据,所有相关联的流程数据。对于系统流程的断定很有帮助。我们在nlapiLoadRecord的返回中可以找到这样对象[undefined, [undefined total=380.00 type=Bill linktype=Order Bill/Invoice]] ;id,l…

刚发现一个未公布的对象,

拿purchaseorder举例,就是

Receipts & Bills😉

这个subtab有于当前业务单据,所有相关联的流程数据。对于系统流程的断定很有帮助。

我们在nlapiLoadRecord的返回中可以找到这样对象

[undefined, [undefined total=380.00 type=Bill linktype=Order Bill/Invoice]] ;id,linktype,linkurl,total,trandate,type

就是这些对象。

nlapiGetContext 应用与介绍-CarlZeng

var currentContext = nlapiGetContext();var procId = currentContext.getSetting(‘SCRIPT’,ncConst.BGP_ProcessIdParam);去读取这个值,难道这个值可以动态被设置?错了, 这个值不可以动态设置!这个Type:SCRIPT是UI级的手工在script地方设置,下面介绍取值的getSetting(…

var currentContext = nlapiGetContext();

var procId = currentContext.getSetting(‘SCRIPT’,ncConst.BGP_ProcessIdParam);

去读取这个值,难道这个值可以动态被设置?

错了, 这个值不可以动态设置!这个Type:SCRIPT是UI级的手工在script地方设置,

下面介绍取值的

getSetting(type, name)
Returns a system or script setting
Important: SCRIPT is the only type supported in Client SuiteScript.

Parameters
? type{string}[required] – The type of script/system setting. Possible values include:
? SCRIPT – script parameter (defined per script)
? SESSION – session variable (volatile setting defined per session)
? FEATURE – returns T (enabled) or F (disabled) depending on whether a feature is
enabled. In the SuiteScript Reference Guide, see “Feature Names and IDs” o
page 335 for all NetSuite feature names and internal IDs.
? PERMISSION – returns permission level: 0 (none), 1 (view), 2 (create), 3 (edit), 4
(full). In the SuiteScript Reference Guide, see “Permission Names and IDs” o
page 327 for all NetSuite permission IDs.
? name {string} [required]- The name of the script/system setting

Important: You must use the nlobContext.getSetting method on nlapiGetContext to reference
script parameters. For example, to obtain the value of a script parameter called
custscript_case_field, you use the following code:
nlapiGetContext().getSetting(‘SCRIPT’, ‘custscript_case_field’)

Returns
? If type is specified as SCRIPT, SESSION, or FEATURE, a string value is returned. If
type is specified as PERMISSION, an integer value is returned.

————————————————————————————————-

下面介绍设置值的:

setSetting(type, name, value)
Sets the value of a script or user-defined setting. Only available in Server SuiteScript.
? type{string} [required] – The type of script/system setting
? SESSION – session variable (volatile setting defined per session)
? name{string} [required]- The name of the script/system setting
? value {string} [required]- The new value for the script/system setting
Returns
? void

所以我们可以知道设置时,仅支持设置SESSION类的东西,其他类不支持。

netsuite弹出窗体的数据回传例子-CarlZeng

netsuite弹出窗体的数据回传例子这样如果顺利,你就能很多开发出一个 弹出的窗体(实现特殊的货品列表),回传单个或多项的货品会销售或采购订单。————————————User Event suitescript beforeloadform.getSubList(‘item’).addButton(‘custpage_name_print’, ‘…

netsuite弹出窗体的数据回传例子

这样如果顺利,你就能很多开发出一个 弹出的窗体(实现特殊的货品列表),回传单个或多项的货品会销售或采购订单。

————————————

User Event suitescript beforeload

form.getSubList(‘item’).addButton(‘custpage_name_print’, ‘添加选配件’, “nlOpenWindow(‘suitelet url &item=’+passitem,750,500,true)”);

说明:nlOpenWindow(‘/app/common/search/search.nl?l=T&searchtype=Item’,750,500,true); 这个是用来实现弹窗的。

现在的关键就是在suitelet中抓取这个passitem,然后通过这个条件按一定规律给用户生成一个item的列表,供用户选择和回传数据。

suitelet: sublist

netsuite固定资产模块-CarlZeng

下面介绍一下,我分析 资产, 财产asset的一些结论,全是netsuite的固定资产解决方案,希望对您有些帮助。~总体分类如下:模块一:proposal 提议; 建议模块二:资产dispose处理,模块三:revaluation再评估,模块四:depreciation折旧,模块五:registerReport资产注册报表,模块六:DepreciationScheduleReport折旧定期报表,…

下面介绍一下,我分析 资产, 财产asset的一些结论,全是netsuite的固定资产解决方案,希望对您有些帮助。~
总体分类如下:

模块一:proposal 提议; 建议
模块二:资产dispose处理,
模块三:revaluation再评估,
模块四:depreciation折旧,
模块五:registerReport资产注册报表,
模块六:DepreciationScheduleReport折旧定期报表,
模块七:AssetsStatus固定资产状态,
模块八:SystemSetup注册安装模块
模块九:SummaryReport汇总报表

模块一:proposal 提议; 建议

——————————————————————– 以下是操作界面:proposal 提议

function ncFAR_ProposalSL(request, response)
{
var RKResp = nlapiRequestURL( RKcheckURL, null, RKparams ); // params now passed as custom headers
var RKresult = RKResp.getBody().split(‘:’); 请求一个验证注册的sl,然后进一步判断。

if (request.getMethod() == ‘GET’) // page display
{
var Params = new Array();
ncFAR_RenderProposalForm(PropList,’Edit’,null,null,Params); //初始化一个列表,或sublist
response.writePage(PropList);
}
else // user submit
{
var rParams = request.getAllParameters();

if( rParams[‘ncactionid’] == ‘Propose’ ) //动作1:建议
else if( rParams[‘ncactionid’] == ‘Generate’ )//动作2:生成
var ProposalList = new Array();
for(var i=1; i<=request.getLineItemCount(‘proposals’); ++i) //在最开始的页面上,submit后直接getLineItemCount ;经典应用!
else if( rParams[‘ncactionid’] == ‘Reject’ ) //动作3:拒绝
for(var i=1; i<=request.getLineItemCount(‘proposals’); ++i) //经典应用zeng.cz200901051710;说明了submit以后request本身成为了一种Record可以直接getLineItemValue等动作,这个应用非常经典。其他main的变量都可以request.getAllParameters()中取道。
{
if( request.getLineItemValue(‘proposals’,’marked’,i) == ‘T’ )
{
nlapiSubmitField(ncConst.FAR_Proposal,request.getLineItemValue(‘proposals’,’id’,i),
‘custrecord_propstatus’,’4′,false); // 10 units not 30!
}
}

}

function ncFAR_RenderProposalForm(form,recState,id,rec,params) //This function builds the tabs, fields and buttons for the Asset Proposal window
{
// header area Filter expressions
var f_msAssetType = params[‘filter_msAssetType’];
if( f_msAssetType == null ) f_msAssetType = ”;

var fld0 = form.addField(‘ncactionid’,’text’,’Action Id’);
fld0.setDisplayType(‘hidden’);
fld0.setDefaultValue(”);

var pList = form.addSubList(‘proposals’,’list’,’Proposed Assets’);

pList.addField(‘editurl’,’url’,’Edit’,true).setLinkText(‘Edit’);
pList.addField(‘custrecord_propassetdescr’,’text’,’Description’).setDisplayType(‘inline’); //简写经典应用。
pList.addField(‘custrecord_propaccmethod’,’select’,’Depreciation Method’,ncConst.FAR_DeprMethod).setDisplayType(‘inline’);
pList.addField(‘custrecord_propassetcost’,’currency’,’Initial Cost’).setDisplayType(‘inline’);

pList.addMarkAllButtons();

form.addSubmitButton(‘Refresh’);
form.addButton(‘Propose’,’Propose New Assets’,”if (window.isinited && window.isvalid && save_record(true)){main_form.ncactionid.value=’Propose’;main_form.submit();}”);
form.addButton(‘Generate’,’Generate Assets’,”if (window.isinited && window.isvalid && save_record(true)){main_form.ncactionid.value=’Generate’;main_form.submit();}”);
form.addButton(‘Reject’,’Reject Proposals’,”if (window.isinited && window.isvalid && save_record(true)){main_form.ncactionid.value=’Reject’;main_form.submit();}”); //经典应用2:main_form.ncactionid.value=’Propose’ 这样给一个’ncactionid’ 页面隐藏的变量赋值了!! 然后main_form.submit()以后request.getAllParameters()就可以得到所有这些字段的值(包括隐藏的字段),然后再if( rParams[‘ncactionid’] == ‘Propose’ )进行动作判断。
200901051702
zeng.cz

动作 完毕!~ 书写系统日志 经典:

/* ncBGP_WriteToLog – utility function to write to the Background Process Manager log table
*
* This function will create a new NC Process Log record using the details provided
*
* Parameters:
* ProcessId – the id of the current process record
* RecordRef – a reference for the current record being processed or which the message relates to
* MessageText – the message text to be written to the log
* MessageType – the type of message, ‘Error’, ‘Warning’ or ‘Message’
*/
function ncBGP_WriteToLog(ProcessId,RecordRef,MessageText,MessageType)
{
var l_MsgType;
switch (MessageType)
{
case ‘Error’:
l_MsgType = 1;
break;

case ‘Warning’:
l_MsgType = 2;
break;

case ‘Message’:
default:
l_MsgType = 3;
}

var LogRec = nlapiCreateRecord(‘customrecord_ncbgp_processlog’);
LogRec.setFieldValue(‘custrecord_logprocessid’,ProcessId);
LogRec.setFieldValue(‘custrecord_logrecordref’,RecordRef);
LogRec.setFieldValue(‘custrecord_logmessagetype’,l_MsgType);
LogRec.setFieldValue(‘custrecord_logmessagedetail’,MessageText);
nlapiSubmitRecord(LogRec,false);
}

模块二:dispose 处理;处置

DisposalPageInit – Event Script for Page Init to disable or enable fields
Once sold or disposed, everything should be read-only

onload. assetid change
var Rec = nlapiLoadRecord(‘customrecord_ncfar_asset’, Id);
nlapiSetFieldValue(‘assetdescr’, ncToEmptyString(Rec.getFieldValue(‘custrecord_assetdescr’)));
DisposalPageInit();

AssetOnSave
Please select a Disposal Type
Sale amount must be greater than zero

——————————————————————– 以下是操作界面:dispose 处理

1,ncFAR_RenderDisposalForm(DisposalForm,’New’,null,null,Params);

2,submit后创建form; 总体circle的经典应用

var dParams = request.getAllParameters();
var assetId = dParams[‘assetid’];
var dAsset;
if( (assetId != null) && (assetId != ”) )
{
dAsset = nlapiLoadRecord(ncConst.FAR_Asset, assetId);
}

var result = AssetDisposal(dAsset, assetId, dParams); //根据提交的id 和变量信息,提交给第三步的事务处理来解决
if(result !=”)
{
// disposal failed
ncFAR_RenderDisposalForm(DisposalForm, ‘Error’, assetId, dAsset, dParams,result); //如果出错则 创建form
response.writePage(DisposalForm);
}
else
{
//disposal successful – redirect to full view of asset //如果成功,直接跳转业务流程。
response.sendRedirect(‘RECORD’,ncConst.FAR_Asset,assetId,false); //suitelet良好应用sendRedirect

3,处理特殊具体的事务

* Generate disposal journal and update asset status.
* Generate asset history record.
* If a Sale, create Sales Invoice record and update link on Asset.

// if Sale
if( DispType == 1 )
var usermsg = ‘
Failed to create invoice for asset sale.
Check setup of location and subsidiary on asset record.’;
var result = CreateJournalEntry(DispDate,CurrencyId,FixedExchangeRate,accts,debits,credits,refs,JournalId,Subsid,ClassId,DepartmentId,LocationId);
fNames = new Array(‘custrecord_assetstatus’, ‘custrecord_assetdepractive’,’custrecord_assetbookvalue’,’custrecord_assetdisposaldate’, ‘custrecord_assetdisposaltype’, ‘custrecord_assetdisposalitem’, ‘custrecord_assetsalecustomer’, ‘custrecord_assetsaleamount’, ‘custrecord_assetsalesinvoice’);
fValues = new Array(‘4’, ‘2’,’0.00′,DispDate, DispType, SaleItem, CustomerId, SaleAmount, SIrecId);
nlapiSubmitField(‘customrecord_ncfar_asset’, id, fNames, fValues, ‘F’); //经典应用,数组批量的submitField
// if Write Off
else if( DispType == 2 )
msg = result + ‘
Journal entry for asset write-off not created.’; //make JE
nlapiSubmitField(‘customrecord_ncfar_asset’, id, fNames, fValues, ‘F’);//更新资产
var rDeprHist = nlapiCreateRecord(ncConst.FAR_DeprHistory); //书写历史。

模块三:revaluation 再评估

if(nlapiGetFieldText(‘assetstatus’) == ‘Disposed’)
alert(‘This asset has been disposed.’);

save
Revaluation details must be supplied;

——————————————————————– 以下是操作界面:revaluation 再评估

三个结构,思路很清晰:

1。构造主界面如果是request.getMethod() == ‘GET’) // page display显示
构造初始form然后writePage。 else 获得request 的参数开始运算过程

2。书写构造form的函数,subtab等的界面按钮等。

3。ncFAR_ProcessRevaluation进行运算。书写JE,完成系统内部联系。

模块四:depreciation 折旧

/* DeprMethodOnSave – Event Script to invoke validation and display error if failed (and prevent save)
*
* This function will use SL_DeprMethodValidate (suitelet function) to validate the formula.
* If the formula parses successfully it will continue the save operation.
* If the formula fails an error is displayed and the save is aborted.
*/

var SLparams = new Array();
SLparams[‘deprmethodformula’] = l_Fn;
SLparams[‘render’] = ‘false’;
var OnSaveURL = nlapiResolveURL(‘SUITELET’,’customscript_ncfar_deprmethodvalidate’,’customdeploy_ncfar_deprmethodvalidate’,true);
var OnSaveResp = nlapiRequestURL( OnSaveURL, SLparams );
var OnSaveResult = OnSaveResp.getBody().split(‘~’);

if( OnSaveResult[0] == ‘OK’ )
{

document.all.item(‘divNCFN’).innerHTML = OnSaveResult[1];
alert(‘Function validated successfully. Please review formula representation.’);

——————————————————————– 以下是操作界面:RenderDepreciate

留在后期在补充。。200812111500

var fNames = new Array();
fNames[0] = ‘custrecord_currentprocessstatus’;
fNames[1] = ‘custrecord_processactivitytype’;
fNames[2] = ‘custrecord_numrecordsprocessed’;
fNames[3] = ‘custrecord_processfailuremessage’;
fNames[4] = ‘custrecord_processparamnames’;
fNames[5] = ‘custrecord_processparamvalues’;
var fValues = new Array();
fValues[0] = ‘1’; // status 1 = in progress
fValues[1] = ‘1’; // activity type 1 = custom (direct call)
fValues[2] = ‘0’; // reset record count
fValues[3] = ”; // reset error message
fValues[4] = ‘ATarray,ATypes,DeprPeriod’;
fValues[5] = ATlist+’,’+ATlist+’,’+DeprPeriodDate;

nlapiSubmitField(ncConst.NC_ProcessActivity, ProcessId, fNames, fValues, false); //经典应用,….数组赋值,多字段submit,ncConst.NC_ProcessActivity 全局变量中取值
ncFAR_DepreciateAssetBG(ProcessId); //should be in main transfer function

模块五:registerReport 资产注册报表

Client code for Asset Register Report scriptlet

ncFAR_AssetRegisterReportSL – entry point for Asset Register Report Scriptlet

form.addSubmitButton(‘Generate Report’);

suitelet:

var AssetReportForm = nlapiCreateForm(‘Asset Register Report’);

var ReportOptions = new Array();

if (request.getMethod() == ‘GET’) // page display //在显示之前,先把form等变量定义好
{
var Params = new Array();
ncFAR_RenderReportOptionsForm(AssetReportForm,’Edit’,null,null,Params);
response.writePage(AssetReportForm);
}
else // user submit
{
var rParams = request.getAllParameters(); //这个方法 取得那些变量

ReportOptions[0] = rParams[‘filtermsassettype’];
ReportOptions[1] = rParams[‘filtermssubsid’];

var fld_rptData = AssetReportForm.addField(‘reportdata’, ‘inlinehtml’, ”); //用户点击提交后改变或添加一些field,然后设置值 然后再writePage 这个form即可!! 经典应用!高效 的动态刷新了页面。
fld_rptData.setDisplayType(‘inline’); //因为是inlinehtml的类型 并且设置显示类型:inline 所以结构就灵活了。。。
fld_rptData.setDefaultValue( ncFAR_BuildReportData(ReportOptions, response) );
response.writePage(AssetReportForm);
}

模块六:Depreciation Schedule Report 折旧定期报表

// aiming to make the following table structure:
//
// [ ][ Asset Type Name 1 ][ Asset Type Name 2 ]…
// [‘Asset’][Asset No.
Name][Asset No.
Name]… [Asset No.
Name][Asset No.
Name]…
// [period1][depr amt][nbv amt][depr amt][nbv amt] [depr amt][nbv amt][depr amt][nbv amt]
// [period2][depr amt][nbv amt][depr amt][nbv amt] [depr amt][nbv amt][depr amt][nbv amt]
// [… ][depr amt][nbv amt][depr amt][nbv amt] [depr amt][nbv amt][depr amt][nbv amt]
//
// so, outer table for 3 columns, n periods + 2 rows; each row (except first) contains sub-table for cols 2 and 3

while( (srAT != null) && (i < srAT.length) )
{
while( (srAssets != null) && (j < srAssets.length) )
{ ++j;
}
++i;
}

Asset Depreciation Schedule – Period Depreciation 折旧期间

Asset Depreciation Schedule – Net Book Value

模块七: Fixed Assets Status固定资产状态

处理状态报告,搜索状态表,
var sr = nlapiSearchRecord(‘customrecord_ncbgp_processcontrol’,null,sf,sc);

var rProcessInfo = sr[0];
var procStatus = rProcessInfo.getValue(‘custrecord_currentprocessstatus’); //get text
var procStatusText = rProcessInfo.getText(‘custrecord_currentprocessstatus’);
var l_RecordCount = rProcessInfo.getValue(‘custrecord_numrecordsprocessed’);

fld_1.setDefaultValue(procStatusText);

var _InProgress = false;
if(procStatus == ‘1’ || procStatus == ‘5’) // In Progress or In Queue
_InProgress = true;

if(_InProgress)

else // processing complete
{
fld_3.setDefaultValue(l_RecordCount + ‘ assets(s) have been depreciated.’);
}

模块八: SystemSetup注册安装模块

三个结构,思路很清晰:

1。构造主界面如果是request.getMethod() == ‘GET’) // page display显示
构造初始form然后writePage。 else 获得request 的参数开始运算过程

2。先判断是new的setup还是edit的form,然后书写构造form的函数,subtab等的界面及按钮等。
如果有ncConst.FAR_SystemSetup记录的话,把默认的系统设置带出来,并且把配置信息子标签和内容都弄出来。
如果没有就只弄出界面而已,不包含配置Subsidiaries、Departments、Locations、Classes、Jobs、Multiple Currencies的checkbox。

ncFAR_RenderSetupForm(form,setupState,id,rec)
var fld1 = form.addField(‘farsetupautopropose’, ‘checkbox’, ‘Auto-Propose from Asset Accounts’, ”, ‘custpagesettings’);
var fld1b = form.addField(‘farsetupautocreate’, ‘checkbox’, ‘Auto-Create from Asset Accounts’, ”, ‘custpagesettings’);
var fld2 = form.addField(‘farsetuppostlocation’, ‘checkbox’, ‘Post on Location Change’, ”, ‘custpagesettings’);
var fld3 = form.addField(‘farsetuppostclass’, ‘checkbox’, ‘Post on Class Change’, ”, ‘custpagesettings’);
var fld4 = form.addField(‘farsetuppostdepartment’, ‘checkbox’, ‘Post on Department Change’, ”, ‘custpagesettings’);
var fld4b = form.addField(‘farsetupsummaryjournals’, ‘checkbox’, ‘Summarise Depreciation Journals’, ”, ‘custpagesettings’
var fldAFD = form.addField(‘farsetupfuturedepreciations’, ‘checkbox’, ‘Allow Future-dated Depreciation’, ”, ‘custpagesettings’);
if (setupState == ‘Edit’) // 如果是要编辑一些系统设置的话,
{
fld1.setDefaultValue(rec.getFieldValue(‘custrecord_autopropose’));
form.addTab(‘custpagefeatures’, ‘Features’);

var fld6 = form.addField(‘farsetupsubsidsenabled’, ‘checkbox’, ‘Subsidiaries’, ”, ‘custpagefeatures’);
var hiddenIDField = form.addField(‘hidden_field’, ‘text’, ‘hidden’);
hiddenIDField.setDisplayType(‘hidden’);
hiddenIDField.setDefaultValue(id); //如果是编辑,把id带过去。
form.addSubmitButton(‘Save’);
}
else
{
fld1.setDefaultValue(‘T’); // checked
fld1b.setDefaultValue(‘T’); // checked
form.addSubmitButton(‘Submit’);
}

3。else(即submit后)进行运算:先CreateRecord创建记录

var rec = nlapiCreateRecord(ncConst.FAR_SystemSetup);
rec.setFieldValue(‘custrecord_allowfuturedepr’, request.getParameter(‘farsetupfuturedepreciations’));
rec.setFieldValue(‘custrecord_subsidsenabled’, currentContext.getSetting(‘FEATURE’, ‘subsidiaries’));
var id = request.getParameter(‘hidden_field’); //用request中隐含字段带出id
if( id != null )
{
rec.setFieldValue(‘id’, id); //关键语句
}
try {
id = nlapiSubmitRecord(rec); //关键语句;经典应用,如果是edit的话(有id),submitRecord系统就会更新原有记录,如果没有就会创建一条!!
} catch (e) {
if ( e instanceof nlobjError )
nlapiLogExecution(‘Error’,’System Setup Suitelet’, e.getCode() + ‘n’ + e.getDetails());
else
nlapiLogExecution(‘Error’,’System Setup Suitelet’, e.toString());
}

var form = nlapiCreateForm(‘Fixed Assets Register’); //经典应用二! submit后直接在CreateForm然后把id赋予直接创建form然后writePage.!!  完美circle!
ncFAR_RenderSetupForm(form,’Edit’,id,rec);
response.writePage(form);

模块九:SummaryReport汇总报表

关键点:ncFAR_BuildReportData(ReportOptions)
* This function will read through the Asset data, filtering by the given Report
* Options, and convert the results to HTML
*
* Parameters: ReportOptions – Array of range values to restrict the report data

模块十:核心主函数

if( currentContext.getSetting(‘FEATURE’,’multicurrency’) == ‘T’ ) //for what?
{
sColumns[sColumns.length] = new nlobjSearchColumn(‘currency’); // N.B. this (as at 9 Nov 2007) will return currency id (not name)
sColumns[sColumns.length] = new nlobjSearchColumn(‘exchangerate’); //good way!~`
}

全局变量设定:

/* ************* Shared Constant Values ************* */

function ncConst() // dummy constructor for ncConst object which will contain our Record Type constants
{
}

ncConst.BGP_ProcessIdParam = ‘custscript_bgp_processid’; /* parameter name for Process Id on scheduled script deployments */
ncConst.BGP_ProcessIdParam2 =’custscript_bgp_startprocessid’; /* parameter name for Process Id on additional scheduled script deployments */

//–SEARCHBLOCK:customrecord – replace these values on deployment
ncConst.FAR_SystemSetup = ‘customrecord_ncfar_systemsetup’; /* record type for System Setup */
ncConst.FAR_AssetType = ‘customrecord_ncfar_assettype’; /* record type for Asset Type */
ncConst.FAR_DeprMethod = ‘customrecord_ncfar_deprmethod’; /* record type for Deprecation Method */
ncConst.FAR_Asset = ‘customrecord_ncfar_asset’; /* record type for Asset */
ncConst.FAR_Proposal = ‘customrecord_ncfar_assetproposal’; /* record type for Asset Proposal */
ncConst.FAR_AssetUsage = ‘customrecord_ncfar_assetusage’; /* record type for Asset Usage */
ncConst.FAR_DeprHistory = ‘customrecord_ncfar_deprhistory’; /* record type for Depreciation History */
ncConst.FAR_XferAccounts = ‘customrecord_ncfar_transferaccounts’; /* record type for Asset Transfer Accounts */
ncConst.NC_ProcessActivity = ‘customrecord_ncbgp_processcontrol’; /* record type for Process Activity */
ncConst.NC_ProcessLog = ‘customrecord_ncbgp_processlog’; /* record type for Process Log */

netsuite凭证批量打印中涉及的html分页打印问题,页面的部分打印-CarlZeng

zeng.cz在打印HTML页面时控制分页,可以使用层来动态控制。 具体的方法是,在需要分页的地方动态添加如下代码: 这是一个经典应用,如果netsuite中涉及的批量凭证打印 需要用这个来控制每张凭证的页面的。很重要,因为html打印是无法像pdf那样的位置决定性。如果一个页面中的表格被分摊到不同的页面来打印了:无标题文档每页都有的表头表格内容表格内容表格内容表格内容表格内容表格内容表格内容…

zeng.cz

在打印HTML页面时控制分页,可以使用层来动态控制。

具体的方法是,在需要分页的地方动态添加如下代码:

这是一个经典应用,如果netsuite中涉及的批量凭证打印 需要用这个来控制每张凭证的页面的。很重要,因为html打印是无法像pdf那样的位置决定性。

如果一个页面中的表格被分摊到不同的页面来打印了:





无标题文档

































每页都有的表头
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
表格内容表格内容
每页都有的表尾



总体方案的确认:

一、浏览器的打印功能菜单
这种方案的优势是不需要对浏览器作任何扩充,是最简单的办法,但问题也最多,如:
1. 不能精确分页。
浏览器一般是根据用户设置的页面大小,web页面的内容多少,来自行决定分页位置,程序员很难控制。会有页脚页眉干扰。
2. 不能准确对齐边边距及打印文字。
3. 不能解决连续打印。
比如,不是仅打印一张票据,而是连续一次打印若干个票据。

二、使用webbrowser控件+ javascript
这实际上,是浏览器打印功能菜单的一种程序调用,与打印功能菜单没什么两样。分页的问题仍然存在,只不过,可以让用户不用去点菜单,直接在网页中的一个按钮,或一个链接里面调用罢了。

三、使用print css
这是一种最理想的实现web套打的方法。这种方法通过在html文档中,嵌入打印相关的css样式,来实现对html文档输出打印的控制,比如设置纸张大小,纸张纵横方向,打印边距,分页等。显而易见,这种方式成本小,不需要下载任何插件,而且跨平台性非常好。print css推出已经有些时日,但遗憾的是,至今
没有一个厂商的浏览器很好地实现了这些标准,这使得程序员目前还不能利用print css进行实际的开发。关于打印css,参见http://css-discuss.incutio.com/?page=PrintStylesheets

四、使用pdf文件
用这种方式,就是从服务器端下载一个pdf文件流,在IE中用adobe插件打开,然后用adobe的打印菜单进行打印,虽然这种方案,也能实现精确套打,但需要下载adobe插件。这是国外报表工具经常推荐的一种打印方法,但在pdf不那么普及的中国,这种方案不是最好选择。

七、轻量级的ActiveX打印方式
这是本公司应客户要求,最新推出的一种最具创意的web套打解决方案。
杰表作为一款纯java的报表工具,以前的提供的web套打方案也是基于Applet的,Applet也做到了尽可能的小(只有24kb),但用户还是抱怨,因为jre太大,安装需要耐心。另外,用Applet方式,很难实现客户端的批量打印功能。

我们采用轻量级的ActiveX打印方案,很好地解决了客户的问题。以下是一个典型的该种方案的示例。

轻量级的ActiveX打印方案的优点是:
1.效率高。可以直接打印指定的html文档,不必向后台再次提起请求。
2.能做到精确打印,分页;
3.功能丰富。可以利用该控件,实现对当前票据文档的打印,预览,及多个html文档的连续打印。
4.成本低廉,ActiveX只有20kb。、

http://www.jatools.com/print/ 这是一个收费的东西,可以找找那些绿色版的,

==================netsuite凭证批量打印中涉及的html分页打印问题,页面的部分打印

window.print() 实际上,是浏览器打印功能菜单的一种程序调用。与点击打印功能菜单一样,不能精确分页,不能设置纸型,套打的问题更加无从谈起,只不过,可以让用户不用去点菜单,直接点击网页中的一个按钮,或一个链接里面调用罢了。事实上,很多用户都是采用这种方式打印,但是这种方式最致命的缺点是不能设置打印参数,比如纸型,页边距,选择打印机等等。

需要指出的是这种方法提供一个打印前和打印后的事件onbeforeprint、onafterprint。可以在打印前的时候重新编辑一些格式,专门送去打印,打印后又处理回来。
function window.onbeforeprint()
{
//将一些不需要打印的隐藏
}
function window.onafterprint()
{
//放开隐藏的元素
}

通过这两个方法,就可以实现页面的部分打印