我想要在查看模式下使用我尝试过的message.create模块创建一条确认消息,如以下代码所示:首先,我在查看模式下获取一个用户事件脚本,并在加载前添加一个按钮,单击该按钮时,客户端脚本将被触发以创建消息/** *@NApiVersion2.x* @NScriptType UserEventScript * @NModuleScope SameAccount */ define('N/ui/serverWidget',
函数(Ui){
/**
* Function definition to be triggered before record is loaded.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord - New record
* @param {string} scriptContext.type - Trigger type
* @param {Form} scriptContext.form - Current form
* @Since 2015.2
*/
function beforeLoad(scriptContext) {
if (scriptContext.type !== scriptContext.UserEventType.VIEW)
{
log.debug("triggered");
var Form=scriptContext.form;
Form.addButton({
id : 'custpage_message',
label : 'message',
functionName:'message'
});
form.clientScriptFileId = 18249;
}
}
return {
beforeLoad: beforeLoad,
};});这是我的客户端脚本: /** * @NApiVersion 2.x * @NScriptType ClientScript * @NModuleScope SameAccount */ define('N/ui/message',
函数(消息){
/**
* Function to be executed after page is initialized.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.currentRecord - Current form record
* @param {string} scriptContext.mode - The mode in which the record is being accessed (create, copy, or edit)
*
* @since 2015.2
*/
function pageInit(scriptContext) {
}
function message()
{
var myMsg = message.create({
title: "My Title",
message: "My Message",
type: message.Type.CONFIRMATION
});
}
return {
pageInit: pageInit,
message:message
};});
发布于 2018-08-21 15:33:08
I函数冲突。只需将消息函数重命名并尝试即可。
发布于 2018-08-21 19:06:28
var myMsg = message.create({
title: "My Title",
message: "My Message",
type: message.Type.CONFIRMATION
});
myMsg.show(); -- you missed that statement--用户事件脚本中
if (scriptContext.type !== scriptContext.UserEventType.VIEW)
{
log.debug("triggered");
var Form=scriptContext.form;
Form.addButton({
id : 'custpage_message',
label : 'message',
functionName:'testmessage()'
});
Form.clientScriptFileId = 115069;
}与上面的代码视图模式一样,但没有创建,因为你检查类型不等于视图。
发布于 2018-08-21 20:45:30
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/ui/message'],
function(message) {
function pageInit(scriptContext) {
}
function testmessage()
{
debugger;
var myMsg = message.create({
title: "My Title",
message: "My Message",
type: message.Type.CONFIRMATION
});
myMsg.show();
}
return {
pageInit: pageInit,
testmessage:testmessage
};
});
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define([],
function() {
/**
* Function definition to be triggered before record is loaded.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord - New record
* @param {string} scriptContext.type - Trigger type
* @param {Form} scriptContext.form - Current form
* @Since 2015.2
*/
function beforeLoad(scriptContext) {
if (scriptContext.type == scriptContext.UserEventType.VIEW)
{
log.debug("triggered");
var Form=scriptContext.form;
Form.addButton({
id : 'custpage_message',
label : 'message',
functionName:'testmessage'
});
Form.clientScriptFileId = 115069;
}
}
return {
beforeLoad: beforeLoad
};
});https://stackoverflow.com/questions/51935346
复制相似问题