Add a Preview Link for an HTML Field

sylvain_hauser
Tera Contributor

Hi.
Because the HTML field doesn't show what exactly the content will be, we are trying to create a "preview" link in the KB submission, such as in the Catalog item, but for the solution.

I attach how the preview is set up for the Catalog item, but I have no idea how to do the same for submission...

I you have any idea...

5 REPLIES 5

kcaldwell
Kilo Expert

I wasn't exactly sure what you were looking for but if it is to preview a KB Submission here you go. I noticed that in the Demo instance Service-now has added kb_view to the list of UI Pages so I modified it, named it kb_preview, and attached it here. I changed the extension to ".txt" so I could attach. Just change the ".txt" to ".xml" and import to the "UI Page" table.

You wil also need to create a Client UI Action called "Preview" for example on the "kb_submission" table with Form Button checked off.



function preview(){

var kb_sys_id = document.getElementById('sysparm_sys_id').getAttribute('value');

var features = "resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,width=800,height=600";
var href ='kb_preview.do?sys_kb_id=' + kb_sys_id + '&sysparm_kbtable=kb_submission';

win = window.open(href, "kb_preview", features);
win.focus();

}


Perfect, you helped me a lot!

I updated the UI page to change the reference table and deleted 2-3 things, and now it is working great.

Here is the kb_preview code I am using now and a screenshot of the ui action (attachment)

Thanks a lot, it is really a huge improvement for our customer


Hi ,

I have a service now instance and the Preview Link is displaying the script "JavaScript: popupOpenStandard("./com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=977d1d483956a400234a6792679dedd5" rather than a hyperlink and opens an error page when clicked on it.
This script is given in Dictionary..I want the hyperlink to be displayed and i am unable to locate where the changes has to be made.


Sylvain,

It appears that once the preview dictionary entry has its type changed from the default "catalog_preview" it cannot be changed back. What I would recommend is exporting the preview dictionary entry from the demo site and importing it into your instance. This should set the link back to its original format.

Hope this helps!