UI Builder -Why does Document Display component overlay entire tab?

bradwestvig
Giga Guru

I'm looking to use the Document Display component to show our users a document while they are working on a related record.  I would like it to stay in the sidebar, similar to the attachment list or templates.  But no matter where I've tried to use Document Display it uses the entire tab, and you can't see the related content.

 

Here you see add the component document display and set an attachment for reference.

2023-01-05_11-52-32.png

 

The side bar shows 

2023-01-05_11-53-02.png

Then when you click on it this happens

2023-01-05_11-53-43.png

 

Is there a better approach?

1 ACCEPTED SOLUTION

Hello @bradwestvig@tstocking and @Stephen Farrar, I managed to solve this by creating a container (Layouts -> Flexbox) with the following CSS settings for the internal layer:

 

 

{
    display: flex;
    flex-direction: column;
    height: 1500px;
    position: relative;
    width: 100%;
    
}

 

 

 

The key here is the position: relative; property. You can adjust the other settings based on your needs and requirements. Inside this container, insert the Document Viewer component, and it will stay within the container. Hope this helps others who may encounter the same issue.

View solution in original post

9 REPLIES 9

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

 

I'd suggest you to use Contextual Side Bar component here. You can create pages as tabs and then I'd make your life easier to configure them. The layout is also controlled better in Contextual Side Bar component.

 

By the way, is this your custom workspace? I am wondering why you are not using OOTB Record page template.

 

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

bradwestvig
Giga Guru

Thanks @JagjeetSingh.. This helped me get a working solution, but I still wasn't able to use the Document Display component.  I ended up using an iframe and link to the internal ServiceNow document viewer.

Stephen Farrar
ServiceNow Employee
ServiceNow Employee

Hi @bradwestvig 

I'm also trying to use the document display component - though in a portal page, and have experienced the same thing - it seems to 'jump' out of any container that you put it in, the only success I've had in keeping it contained is with a modal dialog.

 

The docs don't seem to suggest this is required, and indeed mention sticking it in a panel. https://developer.servicenow.com/dev.do#!/reference/next-experience/utah/shared-components/sn-docume... 

 

Ideally I'm wanting to have a full page view, with a list of attachments for a given record, and the document display in a panel beside these, where the user can click an attachment and it displays in the document display viewer, without having to open and close modals etc.

 

The other issue I've seen is when the component 'loads' if it doesn't have an attachment ID, it seems to display a no file exists error, with the only option to be to click the x to close the viewer - however once you do that, it doesn't seem to want to display again after that. e.g. updating the attachment ID that you're wanting it to view does not appear to do anything. (again this doesn't seem to occur with it inside a modal, presumably because it doesn't load until after the id is populated and the modal is opened). I've also been able to avoid this particular issue by hiding the component initially (however it's still problematic after that).

 

 

 

Here's a sample of what I've knocked up for my POC:

Page with doc display componentPage with doc display component

 

There are two main containers, an attachment picker at the top, and a doc display container underneath. Visibility of the second container is controlled by an attachment being selected in the first list.

 

Upon load the page looks as expected - great so far, document display can't be seen as expected:

Screen Shot 2023-03-27 at 11.55.03 am.png

 

Clicking an attachment however, the component becomes unhidden as expected, but overlays other data on the screen, rather than showing up underneath the other content as expected given the container layout.

Screen Shot 2023-03-27 at 11.56.27 am.png

 

With doc display opening in a modal (configured for fullscreen) it opens as expected:

Screen Shot 2023-03-27 at 12.01.14 pm.png

Closing with the x for the modal, and having the doc display close button disabled, works as expected, allowing you to close a doc and open the next one.

 

Finally, here's what my page looks like on load, if instead of the modal, I have the doc display component on the page, without any hiding, and with no attachment ID specified (in config attachment sys_id is set to 'static' and shows 'search for a Attachment sys_id' showing 'file does not exist' error:

Screen Shot 2023-03-27 at 12.04.49 pm.png

Note that you can't see the attachment list apart from the headings, and there is a floating x above the created heading (this is the close button for the doc display component), clicking that X returns the page to the normal view with the table showing correctly.

 

It gets even worse if you try to have that data driven, with my 'attachment sys_id' set to my state value @state.attachmentId (which I update when a row is clicked in the list, and is initially null), you get absolutely nothing, not even the X:

Screen Shot 2023-03-27 at 12.10.47 pm.png

 

 

I'm probably going to raise a ticket for this issue, but hopefully this helps someone else trying to use the document display component as of Utah Patch 0 / Mar23 timeframe. Looks like (for a portal page at least) at the moment the only solution is to use it in a modal if you need to use document display.

 

Love to hear if anyone has found any alternatives, I will give the iframe idea a go too showing the document viewer etc - for some reason I thought this component had wider file type support, but I can't seem to find where I saw that in the docs now.

 

 

 

@Stephen Farrar   Did you find out anything new on your side?  I ended up using an iframe to present the document.  It works ok, but I would rather see a component used to control the sizing.  I see a lot of variance in size by each user.