UI Builder and opening a URL in a New Window, NOT a tab....?

DrewW
Mega Sage

I have a workspace that users use to open "Appeal" records.  Each one of these records has 1+ attachments on it.  The user has to open the attachment and pick out data that needs to be recorded on the record.  The attachments are usually PDF's and then come in all shapes and sizes.  The default Attachment sidebar tab stinks for this kind of work because the attachment opens over the record you need to enter the data.  So we build a new sidebar tab that shows all of the attachments and when you click on them they open in a new tab.  We would like them to open in a new window.  

 

I used the Event "Link to destination" to open the URL but that opens it in a browser tab and we need a new window.

 

I tried using a client script and "window.open", "this.window.open" and "document" and all come up as undefined.

 

I even tried a Client Script Include and that did not change anything.

 

Has anyone needed to do this and managed to figure it out?

 

Anyone have any thoughts on other things to try I'm all ears.

 

Please and thanks

 

2 ACCEPTED SOLUTIONS

Maik Skoddow
Tera Patron
Tera Patron

Hi @DrewW 

please check if the answer given at https://www.servicenow.com/community/developer-forum/is-it-possible-to-get-dom-element-via-client-sc... might help you to access the browser objects.

 

Maik

View solution in original post

I saw that one and when I do 

console.log(this);

I get null and I get

TypeError: this is null

when I do console.log(this.window) or console.log(this.document)

 

But as I type this I realize I did not try 

helpers.timing.setTimeout(function() {
    console.log(this.window);
});

Which does turn out to work, which is frustrating.

 

Thank you for posting that again.

 

View solution in original post

7 REPLIES 7

GennyT02
Tera Contributor

Hi, thank you so much for your reply.
I don't know if I'm asking too much, but could you send me some screenshots so I can understand what to insert? I'm not very good at UI Builder and I'm having some difficulties.

As I was saying, I need when the user clicks on the attachment, it opens in a new tab.

Thank you so much in advance

Sorry I do not have the time at the moment to give you a comprehensive run down of each part but here is a short summery.

I could not find a way to change the existing attachment functionality to do what I wanted.  So I added a new tab to the Tab bar on the right side of the default record page.  In the screen shot I circled all of the parts that I added so that I could have a separate list of attachments that allowed me to click on one and have it open in a new window.  So you are going to need to read up on how to create a Data resource and Client Script.

GennyT02
Tera Contributor

Thank you so much for your reply, I really appreciate it.
If you have some time, would you be so kind as to show me the steps?

Thanks again for your replies.