raghav
04/22/2022, 6:35 AMwindow.addEventListener("message", function (e) {
  if (e.data.type === "SESSION_CREATED" && e.data.authenticated === false) {
    window.location.href = "some URL";
  }
  if (e.data.type === "SESSION_LOGGED_OUT") {
    window.location.href = "some URL";
  }
});battk
04/22/2022, 7:08 AMbattk
04/22/2022, 7:09 AMbattk
04/22/2022, 7:10 AMraghav
04/22/2022, 7:11 AM/**
 * @param {nlobjRequest} request Request object
 * @param {nlobjResponse} response Response object
 * @returns {Void} Any output is written via response object
 */
function suitelet(request, response) {
  if (request.getMethod() == 'GET') {
    var context = nlapiGetContext();
    var form = nlapiCreateForm("Test Frame");
    var url = '<https://www.tidio.com/panel/settings/live-chat/chat-page>'
    var content = '<iframe width=600px height=100% style="height:640px;" src=' + url + '></iframe>'
    var newField = form.addField('content', 'inlinehtml', 'TEST IFRAME');
    form.addField('extra', 'inlinehtml', '')
    form.setTitle("TEST");
    newField.setLayoutType('outsidebelow');
    newField.setDefaultValue(content);
    form.addSubmitButton('Submit');
    response.writePage(form);
  }
}
Note: URL is differentbattk
04/22/2022, 7:13 AMbattk
04/22/2022, 7:13 AMraghav
04/22/2022, 7:17 AMbattk
04/22/2022, 7:18 AMraghav
04/24/2022, 5:45 PMbattk
04/24/2022, 7:44 PMraghav
04/25/2022, 8:37 AM/**
 * @param {nlobjRequest} request Request object
 * @param {nlobjResponse} response Response object
 * @returns {Void} Any output is written via response object
 */
function suitelet(request, response) {
  if (request.getMethod() == 'GET') {
    var context = nlapiGetContext();
    var form = nlapiCreateForm("Test Frame");
    form.setScript('customscript_iframe_check');
    var url = '<ifarme url>';
    var content = '<iframe id="checkid" width=600px height=100% style="height:640px;" src=' + url + '></iframe>';
    var newField = form.addField('content', 'inlinehtml', 'TEST IFRAME');
    form.addField('extra', 'inlinehtml', '')
    form.setTitle("TEST");
    newField.setLayoutType('outsidebelow');
    newField.setDefaultValue(content);
    form.addSubmitButton('Submit');
    response.writePage(form);
  }
}raghav
04/25/2022, 8:39 AMfunction pageInit(context) {
   console.log('Hello0');
   var wow = document.getElementById('checkid');
   wow.contentWindow.body.addEventListener('click', iframechechk1());
}
function iframechechk1() {
   console.log('hello1');
   window.addEventListener("click", function (e) {
      console.log('clicked1');
      if (e.data.type === "SESSION_CREATED" && e.data.authenticated === false) {
         window.location.href = "<redirect_uri>"
            + encodeURIComponent("<our suitelet deployment ID>");
      }
      if (e.data.type === "SESSION_LOGGED_OUT") {
         window.location.href = "<redirect_uri>"
            + encodeURIComponent("<our suitelet deployment ID>");
      }
   });
}battk
04/25/2022, 8:53 AMbattk
04/25/2022, 8:53 AMbattk
04/25/2022, 8:53 AMraghav
04/25/2022, 8:56 AMbattk
04/25/2022, 8:56 AMraghav
04/25/2022, 9:00 AMif (e.data.type === "SESSION_CREATED" && e.data.authenticated === false) {
         window.location.href = "<redirect_uri>"
            + encodeURIComponent("<our suitelet deployment ID>");
      }
      if (e.data.type === "SESSION_LOGGED_OUT") {
         window.location.href = "<redirect_uri>"
            + encodeURIComponent("<our suitelet deployment ID>");
      }
Applying addeventlistener to the iframe.
SSO authentication check will be taken care by service now team.
In netsuite a user has already logged in with an sso role, and once he goes to the suitelet to raise some query or a ticket.
The same credentials will be passed onto service now redirect uri, which will enable the chatbot to work.battk
04/25/2022, 9:02 AMbattk
04/25/2022, 9:02 AMwow.contentWindow.body.addEventListener('click', iframechechk1());
window.addEventListener("click", function (e) {battk
04/25/2022, 9:03 AMbattk
04/25/2022, 9:03 AMraghav
04/25/2022, 9:03 AMraghav
04/25/2022, 9:04 AMwindow.addEventListener("message", function (e) {raghav
04/25/2022, 9:05 AMbattk
04/25/2022, 9:05 AMbattk
04/25/2022, 9:05 AMraghav
04/25/2022, 9:07 AMbattk
04/25/2022, 9:08 AMfunction pageInit(context) {
   console.log('Hello0');
   var wow = document.getElementById('checkid');
   wow.contentWindow.body.addEventListener('click', iframechechk1());
}
function iframechechk1() {
   console.log('hello1');
   window.addEventListener("message", function (e) {
      console.log('clicked1');
      if (e.data.type === "SESSION_CREATED" && e.data.authenticated === false) {
         window.location.href = "<redirect_uri>"
            + encodeURIComponent("<our suitelet deployment ID>");
      }
      if (e.data.type === "SESSION_LOGGED_OUT") {
         window.location.href = "<redirect_uri>"
            + encodeURIComponent("<our suitelet deployment ID>");
      }
   });
}battk
04/25/2022, 9:08 AMraghav
04/25/2022, 9:08 AMbattk
04/25/2022, 9:09 AMbattk
04/25/2022, 9:10 AMbattk
04/25/2022, 9:11 AMbattk
04/25/2022, 9:11 AMbattk
04/25/2022, 9:12 AMraghav
04/25/2022, 9:14 AMfunction pageInit(context) {
   console.log('Hello0');
   var wow = document.getElementById('checkid');
   wow.contentWindow.body.addEventListener('mesage', iframechechk1());
}
function iframechechk1() {
   console.log('hello1');
   window.addEventListener("message", function (e) {
      console.log('clicked1');
      if (e.data.type === "SESSION_CREATED" && e.data.authenticated === false) {
         window.location.href = "<redirect_uri>"
            + encodeURIComponent("<our suitelet deployment ID>");
      }
      if (e.data.type === "SESSION_LOGGED_OUT") {
         window.location.href = "<redirect_uri>"
            + encodeURIComponent("<our suitelet deployment ID>");
      }
   });
}raghav
04/25/2022, 9:14 AMbattk
04/25/2022, 9:14 AMraghav
04/25/2022, 9:14 AMbattk
04/25/2022, 9:16 AMbattk
04/25/2022, 9:17 AMbattk
04/25/2022, 9:17 AMbattk
04/25/2022, 9:18 AMbattk
04/25/2022, 9:18 AMraghav
04/25/2022, 9:23 AMbattk
04/25/2022, 9:25 AMraghav
04/25/2022, 9:26 AMbattk
04/25/2022, 9:26 AMbattk
04/25/2022, 9:26 AMbattk
04/25/2022, 9:27 AMraghav
04/25/2022, 9:29 AM