- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 07:21 AM
There is a script editor in the Knowledge article editor where we might be able to write a snippet of scripting that we could bring all the default values into the top of each Knowledge article.
We are populating all these fields to improve search hits for the items.
We would like to bring in at the top (or anywhere in the knowledge article itself) four fields of values from the same form so that they automatically become visible when someone looks at the article.
It would save a lot of unnecessary touches to every Knowledge article.
The four fields are in the lower screenshot.
Ideally, if we can get the first two listed, that would be great. All four would be awesome.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 07:45 AM
Hello @Tom Thompson ,
The script button significance is to insert a sample code but not to execute javascript code.so its not useful in auto populating the HTML field.
I have an idea for this .I just tried a sample thing .
i just created a On load client script on knowledge table like below
function. onLoad()
{
var sr = '<p><span style="font-size: 18pt;"><strong>Excel Functionality</strong></span></p>'+
'<p><span style="font-size: 12pt;"><strong>Knowledge base</strong></span></p>'+g_form.getDisplayBox('kb_knowledge_base').value;
g_form.setValue('text',sr);
}
What i did was there is a source code button <> with this symbol in the same HTML editor beside the code button.You can click on that and copy the entire HTML code and go to client scripts and wrap your entire HTML in single quotes separated by "+" symbol for every line like above script.But when its time to get values from the form use g_form.getDisplayBox('your_field_name').value; just like i did in the above script.This will print the dynamic values which are present on the form.
NOTE: You need to make sure that this script runs only for your knowledge base or article by putting some IF statements like below
function. onLoad()
{
if(g_form.getDisplayBox('kb_knowledge_base').value=="your_knowledge _base_name")
{
var sr = '<p><span style="font-size: 18pt;"><strong>Excel Functionality</strong></span></p>'+
'<p><span style="font-size: 12pt;"><strong>Knowledge base</strong></span></p>'+g_form.getDisplayBox('kb_knowledge_base').value;
g_form.setValue('text',sr); // text is nothing but your HTML field back end name
}
}
Hope this helps
Mark my answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 07:45 AM
Hello @Tom Thompson ,
The script button significance is to insert a sample code but not to execute javascript code.so its not useful in auto populating the HTML field.
I have an idea for this .I just tried a sample thing .
i just created a On load client script on knowledge table like below
function. onLoad()
{
var sr = '<p><span style="font-size: 18pt;"><strong>Excel Functionality</strong></span></p>'+
'<p><span style="font-size: 12pt;"><strong>Knowledge base</strong></span></p>'+g_form.getDisplayBox('kb_knowledge_base').value;
g_form.setValue('text',sr);
}
What i did was there is a source code button <> with this symbol in the same HTML editor beside the code button.You can click on that and copy the entire HTML code and go to client scripts and wrap your entire HTML in single quotes separated by "+" symbol for every line like above script.But when its time to get values from the form use g_form.getDisplayBox('your_field_name').value; just like i did in the above script.This will print the dynamic values which are present on the form.
NOTE: You need to make sure that this script runs only for your knowledge base or article by putting some IF statements like below
function. onLoad()
{
if(g_form.getDisplayBox('kb_knowledge_base').value=="your_knowledge _base_name")
{
var sr = '<p><span style="font-size: 18pt;"><strong>Excel Functionality</strong></span></p>'+
'<p><span style="font-size: 12pt;"><strong>Knowledge base</strong></span></p>'+g_form.getDisplayBox('kb_knowledge_base').value;
g_form.setValue('text',sr); // text is nothing but your HTML field back end name
}
}
Hope this helps
Mark my answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 07:49 AM
Thank you for trying..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 07:01 AM
1. What is the reason for using a custom field for keywords and not the default meta field?
2. Do you use ZING or AI search? It seems a lot of effort for search results improvements if it's Zing. And AI search does it's own thing whatever you do (though snippets and genius results might be useful to your customers https://docs.servicenow.com/en-US/bundle/utah-platform-administration/page/administer/ai-search/conc...)
3. Knowledge blocks could be created and re-used