【问题标题】:Add a button to a results column in NetSuite Saved Searches在 NetSuite Saved Searches 中的结果列中添加一个按钮
【发布时间】:2020-03-12 05:37:53
【问题描述】:

如何向已保存搜索的结果列添加按钮?

我有一个工作流程,当某个字段被更新时,它会向 ITEM 记录添加一个按钮。单击时,该按钮会启动另一个工作流程。

是否可以将此按钮作为链接添加到“已保存的搜索”列中。当用户单击链接时,它将启动按钮操作。这与案例管理中的“GRAB”按钮功能相似。

【问题讨论】:

    标签: netsuite


    【解决方案1】:

    需要更多信息才能完整回答,但简而言之:是的,您可以。您可以创建一个文本公式来构建一个锚元素来创建一个链接 - 例如,下面是一个公式,您可以使用它在项目搜索的每一行上放置一个打印标签链接:

    '<a href="/app/accounting/print/barcodeprinter.nl?itemid=' || {internalid} || '">Print Label</a>'
    

    您仍然需要创建它显示的条件(可能使用CASE 语句)并使用正确的路径和参数构建 url,但这应该可以帮助您入门。

    【讨论】:

    • 谢谢。这似乎是朝着正确方向迈出的一步。我将如何找到要使用的正确 URL?该按钮是通过工作流操作生成的。
    • 使用开发工具检查按钮并寻找点击操作。
    • 我检查了按钮并粘贴了下面的代码。你能帮我创建链接吗?这是我第一次这样做: onclick="try{NS.Workflow.buttonClick('custpageworkflow668');}catch(e){document.location = addParamToURL(addParamToURL(addParamToURL(document.location.href,'workflowbutton', '668'),'workflowbuttoninstanceid','10235697'),'workflowbuttonobsoletehandling','T');}; return false;"
    • 我意识到这是一个旧线程,但是,如果 NetSuite 专家可以帮助实现这个请求的工作流按钮链接功能,那就太好了。
    【解决方案2】:

    您可以使用公式(文本)字段将按钮添加到已保存的搜索结果列并输入如下公式:

    '<button onclick="window.open(`/app/site/hosting/scriptlet.nl?script=123&deploy=1&rec_id=' || {internalid} || '`);">Do Action</button>'
    

    上面将在屏幕上放置一个实际按钮,该按钮将打开一个 Suitelet 以执行操作并编写一些响应页面。如果您希望它保留在该页面上,您可以使用 xhr 请求执行某些操作,如下所示:

    '<button onclick="var xhr = new XMLHttpRequest(); xhr.open(`GET`, `/app/site/hosting/scriptlet.nl?script=123&deploy=1&rec_id=' || {internalid} || '`); xhr.onload = function(oEvent) { var response = JSON.parse(xhr.response); if (xhr.status == 200 && response) { console.log(xhr.response); window.open(`https://system.netsuite.com/app/accounting/transactions/estimate.nl?e=T&id=` + response); } else { console.log(xhr.response); alert(`Issue Doing Button Action`) } };xhr.send(null);this.style.display = `none`;this.parentElement.append(`Button Clicked`);">Do Action</button>'
    

    在这两种情况下,您都需要将那里的 url 更新为适合您的 Suitelet 的 url。在您的情况下,您可能希望创建一个使用 N/workflow 模块来启动或触发您的第二个工作流的 Suitelet。

    要处理“更新某个字段时”部分,您可以执行 case 语句,如下所示:

    CASE WHEN {custbody_your_field} IS NULL THEN 'No Action Available' ELSE '<one of the code snippets above>' END
    

    别忘了 END 语句 :)

    用于启动工作流的示例 Suitelet:

    define(['N/workflow'], function (wf) {
        /**
         * Initiates a workflow
         * 
         * @NApiVersion 2.x
         * @NScriptType Suitelet
         * @author Stephen Lemp (SuiteRep)
         */
        var exports = {};
    
        var WORKFLOW_ID = 1234;
        /**
         * @function onRequest Definition of the Suitelet script trigger point.
         * @governance XXX
         * 
         * @param {Object} params
         * @param {http.ServerRequest} params.request The incoming request.
         * @param {http.ServerResponse} params.response The Suitelet response.
         *
         * @return {void}
         * @since 2015.2
         */
        function onRequest(context) {
            var rec_id = context.request.parameters.rec_id
            var workflowInstanceId = wf.initiate({
                recordType: 'some_record_type', // The record type that the workflow is deployed on.
                recordId: rec_id, // The record ID of some record.
                workflowId: 'customworkflow_some_workflow'
            });
        }
    
        exports.onRequest = onRequest;
        return exports;
    });
    

    【讨论】:

      猜你喜欢
      • 2022-11-09
      • 2021-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-20
      • 1970-01-01
      相关资源
      最近更新 更多