NetSuite: 我如何更改销售订单中的当前子选项卡

huangapple go评论63阅读模式
英文:

NetSuite: How can I change current subtab in SO

问题

我在SO中添加了一个新的交易主体字段。
我想根据自定义选择选项的值来更改当前子选项卡。
我已经添加了客户端脚本。我想知道的是更改当前子选项卡的函数。

EntryPoint.fieldChanged = (scriptContext) => {
const LOGTITLE = "fieldChanged " + scriptContext.currentRecord.id;

try {
    var record = scriptContext.currentRecord;

    if (scriptContext.fieldId == 'custpage_paymentoption') {
        var currentOption = record.getValue({
            fieldId: 'custpage_paymentoption',
        })
        log.debug('currentOption', currentOption);


    }
} catch (e) {
    log.error(LOGTITLE, JSON.stringify(e));
}

};

如您所知,销售订单记录中默认的子选项卡设置为"项目"。我希望在更改自定义选择选项的值后将其更改。
请告诉我是否有人可以给我建议。

英文:

I added a new Transaction Body Field in SO.
And I want to change the current subtab based on the value of the custom select option.
I already add a ClientScript. What I want to know is the function that change current subtab.

EntryPoint.fieldChanged = (scriptContext) => {
    const LOGTITLE = "fieldChanged " + scriptContext.currentRecord.id;
    
    try {
        var record = scriptContext.currentRecord;
    
        if (scriptContext.fieldId == 'custpage_paymentoption') {
            var currentOption = record.getValue({
                fieldId: 'custpage_paymentoption',
            })
            log.debug('currentOption', currentOption);

            
        }
    } catch (e) {
        log.error(LOGTITLE, JSON.stringify(e));
    }
};

As you know, in Sales Order Record default subtab is set as Item. I want to change it after I change the value of the custom select option.
Please let me know if someone can give me advice.

答案1

得分: 1

我注意到您想要更新销售订单中的子选项卡。您可以使用commitLine()函数来实现这一点。以下是示例代码:

/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */

define([], function() {
  function pageInit(context) {
    // 切换到所需的子选项卡
    var sublistId = 'item'; // 包含子选项卡的子列表的ID
    var subtabIndex = 1; // 您想要切换到的子选项卡的索引(从0开始)

    // 选择子选项卡
    context.currentRecord.selectLineItem({
      sublistId: sublistId,
      line: subtabIndex
    });

    // 提交更改以切换到子选项卡
    context.currentRecord.commitLine({
      sublistId: sublistId
    });
  }

  return {
    pageInit: pageInit
  };
});

请注意,这是一段用于NetSuite的客户端脚本示例,用于在销售订单页面中切换到特定子选项卡。

英文:

I noticed you want to update your subtab in SO.
You can achieve this using commitLIne() function.
Under is sample code.

/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */

define([], function() {
  function pageInit(context) {
    // Switch to the desired subtab
    var sublistId = 'item'; // ID of the sublist containing the subtab
    var subtabIndex = 1; // Index of the subtab you want to switch to (0-based)

    // Select the subtab
    context.currentRecord.selectLineItem({
      sublistId: sublistId,
      line: subtabIndex
    });

    // Commit the changes to switch to the subtab
    context.currentRecord.commitLine({
      sublistId: sublistId
    });
  }

  return {
    pageInit: pageInit
  };
});

答案2

得分: 0

如果您的目标是根据字段值更新表单以添加子选项卡,那么无法使用客户端脚本来实现。表单在服务器上设置,而不是在客户端。但是,您可以使用客户端脚本重新加载页面并在URL中添加信息。然后,您可以创建一个用户事件来检查URL中的信息并根据其更新表单。要更新表单,您需要使用服务器小部件模块。

英文:

If your goal is to update the form to add a subtab according to the field value, it isn't possible to do it with a client script.
The form is set on the server and not on the client side.
But you can use you client script to reload the page and add informations inside the url.
You will have a user event that will check the url information and update the form according to it.
To update the form, you need to use the server widget module

答案3

得分: 0

你可以使用(未记录,不受支持的)ShowTab() 函数来切换标签。通过在开发工具中检查标签来获取内部 ID,并使用 ShowTab({{tab_internal_id}}, false) 切换到该标签。有关更多信息,请参阅此SuiteAnswers文章

(这篇文章是关于生成打开特定标签的页面的直接URL,但它包含的信息也将帮助你使用ShowTab()函数。)

英文:

You can use the (undocumented, unsupported) ShowTab() function to switch tabs. Get the internal ID of the tab by inspecting it in the dev tools, and use ShowTab({{tab_internal_id}}, false) to switch to that tab. More information at this SuiteAnswers article.

(The article is about generating a direct URL to a page opened to a specific tab, but it contains information that will help you to use the ShowTab() function also.)

huangapple
  • 本文由 发表于 2023年7月18日 05:42:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76708251.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定