我正在尝试根据NetSuite中的公式设置表单。我希望在用户访问页面之前确定并加载该表单。我使用的代码是UserEventScript,它在beforeLoad函数中。 defineSOForm返回表单的内部ID。
function beforeLoad(scriptContext) {
if (scriptContext.type == scriptContext.UserEventType.CREATE) {
var recNew = scriptContext.newRecord;
var idCustomer = recNew.getValue('entity');
var idUser = runtime.getCurrentUser().id;
var idForm = recNew.getValue('customform');
// Set form from user department
var idNewForm = defaulting.determineSOForm(idUser, null, idCustomer);
if (idForm != idNewForm) {
recNew.setValue({
fieldId : 'customform',
value : idNewForm
});
idForm = idNewForm;
}
}
}
使用脚本调试器,我可以逐步解决这个问题,并且一切正常,但是根本没有设置自定义窗体。我已经了解到无法在UserEvent脚本的beforeLoad事件中设置customform字段,但是现在我迷失了如何完成此操作。
答案 0 :(得分:1)
从客户端脚本而不是用户事件中处理
function pageInit(scriptContext) {
var recNew = scriptContext.currentRecord;
var idCustomer = recNew.getValue('entity');
var idUser = runtime.getCurrentUser().id;
var idForm = recNew.getValue('customform');
// Set form from user department
var idNewForm = defaulting.determineSOForm(idUser, null, idCustomer);
if (idForm != idNewForm) {
recNew.setValue({
fieldId : 'customform',
value : idNewForm
});
idForm = idNewForm;
}
}
答案 1 :(得分:-1)
// Set form from user department
var idNewForm = defaulting.determineSOForm(idUser, null, idCustomer);
idNewfrom value is Customform name then
use below condition
if (idForm != idNewForm) {
recNew.setText({
fieldId : 'customform',
value : idNewForm
});
idForm = idNewForm;
}
idNewfrom value is internalid of form then
use below condition
if (idForm != idNewForm) {
recNew.setValue({
fieldId : 'customform',
value : idNewForm
});
idForm = idNewForm;
}
尝试上面的代码