NetSuite Portlet应用

Portlet是NetSuite的一种脚本类型,应用在Web Part上,作为NetSuite UI中Dashboard的组成部分。我们一般通过它来嵌入外部数据源,来便捷化用户的访问。例如下图所示的地图或者运单查询。

NetSuite Portlet应用_第1张图片

 

NetSuite Portlet应用_第2张图片

实现上述示例的原理是,利用Iframe定义一个URL来源,从而在UI上展示出URL的内容。需要注意的是,出于安全考虑,NetSuite只支持Https开头的网址。

制作步骤如下:

1. Copy如下脚本到一个JS文件。

/**
 * Copyright NetSuite, Inc. 2014 All rights reserved.
 * The following code is a demo prototype. Due to time constraints of a demo,
 * the code may contain bugs, may not accurately reflect user requirements
 * and may not be the best approach. Actual implementation should not reuse
 * this code without due verification.
 *
 * (Module description here. Whole header length should not exceed
 * 100 characters in width. Use another line if needed.)
 *
 * Version    Date            Author           Remarks
 * 1.00       02 Oct 2014     mvictoria
 *
 */

/**
 * @param {nlobjPortlet} portlet Current portlet object
 * @param {Number} column Column position index: 1 = left, 2 = middle, 3 = right
 * @return {void}
 */
function showPDFFileHTMLPortlet(portlet, column) {
    var sPortletTitle = nlapiGetContext().getSetting('SCRIPT', 'custscript_mv_pdf_portlet_title') || '';
    portlet.setTitle(sPortletTitle);
    
    var sPDFFileURL = nlapiGetContext().getSetting('SCRIPT', 'custscript_mv_pdf_portlet_file_url') || '';
    var sHTML = '';
    
    if (sPDFFileURL != '') {
        var sPortletHeight = nlapiGetContext().getSetting('SCRIPT', 'custscript_mv_pdf_portlet_height') || '200';
        
        sHTML += '

';
        sHTML += '';
        sHTML += '
';
    } // end if
    else {
        sHTML = '

Please edit portlet settings to set portlet title, height and PDF file URL.

';
    } // end else
    
    portlet.setHtml(sHTML);
} // end function showPDFFileHTMLPortlet

2.上传、部署此脚本,并设置相应参数。

NetSuite Portlet应用_第3张图片

务必在参数页面中检查两点内容:

  • 参数的ID一定要与上面脚本中红色标注的参数一致。
  • 首选项选择“区块”。

NetSuite Portlet应用_第4张图片

 3.部署成功后在Dashboard中添加“自定义区块”,并选择“ShowPDF”,就是你定义的脚本名称。然后配置一下需要展示的URL和高度就可以了。

NetSuite Portlet应用_第5张图片

 

你可能感兴趣的:(NetSuite开发)