If statement to only open AWS soft phone while in Service Operations Workspace

rstoker
Tera Contributor

Hi. I'm the customer and don't have much coding experience. We recently turned on an integration with AWS Connect. It works great, but interferes when viewing anything outside the Service Operations Workspace. The solution we came up with is to add an if-statement to the javascript that controls the soft phone. Unfortunately, everything we have tried has failed.

 

I think we want to put it somewhere in the OpenFrame Initialization portion of the code. Possibly to skip the entire thing, but I think the if-statement we are using is the problem.

 

We've tried:

if (window.location.href.indexOf("service-now.com/now/sow/"){

if(window.location.contains("service-now.com/now/sow/")){

if (window.location.href.indexOf("sow") > -1{

if window.location.toString().includes("sow")

if (window.location.href.indexOf('sow') !== -1) {

 

etc...

 

 

Someone in our organization recently suggested:  "window.location.href is used on the client side of browser where SNOW uses gs.action.getGlideURI() on the server side to obtain the portion of the URL that you are looking for. "

 

Is that heading down the correct path or are we totally going at this the wrong way?

 

1 ACCEPTED SOLUTION

You can try something like this - just replace those log statements with an alert and return.

 

 

function initCallback(snConfig) {
  if (window.parent.location.href.indexOf("/now/sow/") !== -1) {
    alert("{YOUR MESSAGE}");
    return;
  }
  var openFrameConfig = snConfig;
  if (openFrameConfig.configuration)
    showRecordOnIncomingBehavior = JSON.parse(openFrameConfig.configuration);
  //register for communication event from TopFrame
  openFrameAPI.subscribe('openframe_awa_agent_presence', handleOpenFrameAwaEvent);
  //register event for click to call
  openFrameAPI.subscribe('openframe_communication', handleClickToCall);
  //register for work item accepted event
  openFrameAPI.subscribe('openframe_awa_workitem_accepted', handleWorkItemAccepted);
}

 

 

Good luck!

 

View solution in original post

8 REPLIES 8

Thanks for the suggestion. We added it and got this:
Page location is https://Myinstance.service-now.com//sn_cti_amzn_cct_aws_ccp.do?id=c28df7a3930fce10030979fa2bba10ee

 

This is not the actual location the browser window is in. Is there something we can do to grab that information?

Looks like that's running in a frame. Try adding this statement immediately below the other log statements:

console.log("Parent window location is: " + window.parent.location.href);

Also, consider editing your previous reply to remove your instance name. We're only interested in what's after x.service-now.com/ anyway.

That's it! Thank you so much! Now we just need to play around with putting the if statement in the correct place to only run the code on the page we want.

I'm assuming this will work:

if (window.parent.location.href.indexOf("/now/sow/") !== -1) {
// Do something
}

You can try something like this - just replace those log statements with an alert and return.

 

 

function initCallback(snConfig) {
  if (window.parent.location.href.indexOf("/now/sow/") !== -1) {
    alert("{YOUR MESSAGE}");
    return;
  }
  var openFrameConfig = snConfig;
  if (openFrameConfig.configuration)
    showRecordOnIncomingBehavior = JSON.parse(openFrameConfig.configuration);
  //register for communication event from TopFrame
  openFrameAPI.subscribe('openframe_awa_agent_presence', handleOpenFrameAwaEvent);
  //register event for click to call
  openFrameAPI.subscribe('openframe_communication', handleClickToCall);
  //register for work item accepted event
  openFrameAPI.subscribe('openframe_awa_workitem_accepted', handleWorkItemAccepted);
}

 

 

Good luck!