Opening URL for PDF files

Annette Kitzmil
Tera Guru

Hello,

I relativley new and need some direction on how I would get a pdf document being retrieved from a different system via a url to open the specific form related to the record.  Below is code I attached to a UI action button.  However, I see there are various ways to do this and I am just not sure what the best option is for opening the PDF form.  Does the code look right and/or, is there a better option to accomplish this?

 

var gsRecord;
var url = 'https://fn5digdev.mtb.com/navigator';
var desktop = 'BDA&';
var repository = 'Retail&';
var documentCME_ID = current.u_filenet_document_id;
var templateName = 'dcRetail&';
var version = 'release&';
var embedded = true;

function openURL() {
{

gsRecord = ('url' + 'desktop' + 'respository' + 'documentCME_ID' + 'templateName' + 'version' + 'embedded');

action.setRedirectURL(url);

}

}

1 ACCEPTED SOLUTION

Annette Kitzmil
Tera Guru

Hi @Harsh Vardhan  - I found that and tried what you attached for the regex for removal of the curly brackets and the curly brackets were not removed.  However, I may no longer need them removed, so I believe I am all set and appreciate all of the help.  

View solution in original post

17 REPLIES 17

@Annette Kitzmil Can you share screenshot of your UI action. 

 

Looks like you have called the script inside "function onClick(g_form) {", which will only work for client side but you are calling server side function inside client side block hence its not working.

 

you should call in server side block not client . If you want to understand more how server side and client side function works in UI action, please check below article. 

 

https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/ 

 

 

Hi @Harsh Vardhan - You are correct, I am calling this utilizing a UI action on the server side, not the client side.  I have primarily been exposed to server side and not much client side.  So that is the reason that i went this route.

 

AnnetteKitzmil_0-1692731250464.png

AnnetteKitzmil_1-1692731271380.png

 

 

This wont work. You cannot mix Server and Client Side API like this. The Code you currently have using the server side API ("current" and "gs" are can only be used in server side scripts).

You need to move the Script from the "Workspace Client Script" field to the "Script" field:

MarkusKraus_0-1692732727526.png

 

Hi @Annette Kitzmil  why are you calling inside "Workspace script" ? Your button is visible on workspace ? do you want to use this at workspace or native UI ?

If you are using only at native UI then please move your script in "Script" field . also current and gs method works at server side not client side. 

 

for workspace i had provided solution in the past. Please check below thread. 

 

How to open url into new tab in agent workspace 

 

Hope it will help you. 

 

Thanks,

Harsh

 

Hi @Harsh Vardhan - So I have a button in workspace that I am trying to have open the document.  So if I am doing it this way, then I believe the script is in the right place.  However, it sounds like I need a client side script that works with the UI Action from what you mentioned above.  I am just not sure how to achieve this with tying everything together from the UI Action to the Client Script.  Once I get it done the first time, I will have it, but I am not clear enough on how to accomplish it.  I provided a screen shot of the workspace showing the UI Action button that a user will click in order to open the document.

 

AnnetteKitzmil_0-1692733757022.png