Bibek Shrestha
10/06/2022, 7:47 PMN/ui/message
module to display multiple messages. I’m calling the message.hide()
function to hide a specific message but seems like NetSuite hides a random one every time. Anyone come across this issue and possibly have a solution to it?eblackey
10/06/2022, 7:50 PMBibek Shrestha
10/06/2022, 7:52 PM.hide()
statement and it logs the correct message object.eblackey
10/06/2022, 7:55 PMBibek Shrestha
10/06/2022, 7:59 PMfor (let i = 0; i < data.length; i++) {
const notificationId = data[i]._id;
const msg = message.create({
title: createHtmlTitle(data[i].title, data[i].dismissible, notificationId),
message: createHtmlMessage(data[i].message, data[i].callsToAction),
type: createType(data[i].type)
});
msg.show();
const interval = setInterval(
() => {
if (document.getElementById(`dismiss-${data[i].title}-${notificationId}`)) {
clearInterval(interval);
document.getElementById(`dismiss-${data[i].title}-${notificationId}`).addEventListener("click", (e) => {
console.log("msg to hide: ", msg.toJSON());
msg.hide();
});
}
}, 1000
);
}
dbarnett
10/06/2022, 8:13 PMhide()
by lookup on unique notificiationIddcrsmith
10/06/2022, 8:18 PMdcrsmith
10/06/2022, 8:22 PMduration
in the show() options instead of trying to clear it with an interval??Bibek Shrestha
10/06/2022, 9:36 PMBibek Shrestha
10/06/2022, 9:38 PMdcrsmith
10/06/2022, 9:44 PMfor (let i = 0; i < data.length; i++) {
const notificationId = data[i]._id;
window[notificationId] = message.create({
title: createHtmlTitle(data[i].title, data[i].dismissible, notificationId),
message: createHtmlMessage(data[i].message, data[i].callsToAction),
type: createType(data[i].type)
});
window[notificationId].show();
// TODO: add a close <a> link on the message with the notificationId as the the element ID
// add onclick event and use window[notificationId].hide()
}
dcrsmith
10/06/2022, 9:44 PMdbarnett
10/06/2022, 9:45 PMdbarnett
10/06/2022, 9:45 PMhideAlertBox('message-xxxxxxx')
if you have to resort to finding the correct identifier in DOM and calling manually yourself insteadBibek Shrestha
10/06/2022, 10:07 PMwindow
, again no changeBibek Shrestha
10/06/2022, 10:08 PMdcrsmith
10/06/2022, 11:02 PM/**
* SA-44630 SuiteScript Versioning Guidelines
* SA-43522 SuiteScript 2.x JSDoc Validation
*
* @NApiVersion 2.1
* @NScriptType ClientScript
* @NModuleScope SameAccount
*
* @description clear ns alerts by user click
*
* Created by David Smith on 10/6/2022
*
* @copyright 2022 Blue Banyan Solutions
*/
define(['N/ui/message'], function (message) {
/**
* Function to be executed after page is initialized.
*
* @governance XXX
*
* @param scriptContext
* {Object}
* @param scriptContext.currentRecord
* {Record} Current form record
* @param scriptContext.mode
* {String} The mode in which the record is being accessed (create,
* copy, or edit)
*
* @return {void}
*
* @since 2015.2
*
* @static
* @function pageInit
*/
function pageInit(scriptContext) {
console.log('load ui messages')
window.data = [
{
_id: "msg1",
_message: "this is message 1",
_type: message.Type.CONFIRMATION,
_title: "message one",
dismissible: true
},
{
_id: "msg2",
_message: "this is message 2",
_type: message.Type.INFORMATION,
_title: "message two",
dismissible: true
},
{
_id: "msg3",
_message: "this is message 3",
_type: message.Type.WARNING,
_title: "message three",
dismissible: false
},
{
_id: "msg4",
_message: "this is message 4",
_type: message.Type.ERROR,
_title: "message four",
dismissible: false
}
]
for (let i = 0; i < window.data.length; i++) {
const notificationId = data[i]._id;
console.log(notificationId);
window[notificationId] = message.create({
title: createHtmlTitle(data[i]._title, data[i].dismissible, notificationId),
message: data[i]._message,
type: data[i]._type
});
window[notificationId].show();
}
setTimeout(function(){
for (let i = 0; i < window.data.length; i++) {
const notificationId = window.data[i]._id;
console.log(notificationId);
jQuery('#'+notificationId).click(function(){
console.log(jQuery(this).attr('id'));
window[jQuery(this).attr('id')].hide();
})
}
},2000);
}
function createHtmlTitle(title,dismiss,id){
let t = title + (dismiss?`<a id="${id}" style="float: right;">close ${id}</a>`: '');
return t;
}
return {
pageInit: pageInit
}
});
dbarnett
10/07/2022, 12:19 AMthis.id = "message-" + new Date().getTime();
(in browser Page -> ui/messaging/reskin.js), so again I suspect the underlying issue is them being created too closely in time together - should resolve itself if implement some appropriate delayBibek Shrestha
10/11/2022, 7:14 PM