我正在尝试添加一个按钮,仅当表单的自定义字段具有固定值时才允许完成任务,如果没有,则提醒用户无法完成该任务。
define([], function() {
function completeTaskIfCustomFieldIsTrue() {
var customFieldId = 'custeventcrm_sales_status'; // Replace with the actual custom field ID
var isCustomFieldTrue = document.getElementById(customFieldId).value;
var isStatus = 'status'; //FieldID of status task
if (isCustomFieldTrue == 6) {
// Custom field is true, complete the CRM task
// Add your code here to complete the CRM task
button.onclick = function() {
window.location.href = 'sb2.app.netsuite.com/app/crm/calendar/task.nl?id=|| {internal_id} ||&whence=&cmid=1692983702342_16261';
var isStaus = 'COMPLETE'; // Replace with the desired status
changeTaskStatus(taskId, newStatus);
};
// Append the button to the form
var form = document.getElementById('custform_200_5210436_sb2_536'); // Replace with the actual form ID
form.appendChild(button);
} else {
// Custom field is not true, do nothing
window.alert('Custom field is not true. Skipping CRM task...');
}
}
return {
pageInit: function(context) {
completeTaskIfCustomFieldIsTrue();
}
};
});
我添加了这段代码,但它并没有完全粘在现场
可以将类似的内容添加到已保存的搜索中吗?
谢谢你
NetSuite 不支持也不建议在 NetSuite 页面上进行 DOM 操作。官方立场是,对页面所做的所有更改都必须使用其记录的 API 来完成。实现此目的的正常方法是使用用户事件
beforeLoad()
函数添加一个按钮,并将该按钮绑定到客户端脚本中包含的函数,如这个答案中所述。
HTH.