- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 03:06 PM
Hi All,
I am developing a scripted Rest message Get method, to get the KBs. Here I am not able to get HTML-type fields.
Can someone help me to get HTML in the get method?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 07:38 PM
@Rushi2 Please use the updated code and see if it works for you.
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var val = [];
// implement resource here//
var grchatgpt = new GlideRecord('kb_knowledge');
grchatgpt.addEncodedQuery("workflow_state=published^kb_knowledge_base=100c36a80f115244272e244be1050e88");
grchatgpt.orderByDesc('sys_updated_on');
grchatgpt.query();
while (grchatgpt.next()) {
var abc = grchatgpt.kb_introduction.toString();
var res = {
"Number": grchatgpt.getValue('number'),
"knowledge base": grchatgpt.getDisplayValue('kb_knowledge_base'),
"valid to": grchatgpt.getValue('valid_to'),
"short description": grchatgpt.getValue('short_description'),
"Assignment group": grchatgpt.getDisplayValue('u_assignment_group'),
"Internal notes": grchatgpt.getValue('u_internal_notes'),
"kb instructions": grchatgpt.getValue('kb_instructions'),
"kb support details": grchatgpt.getValue('u_kb_support_details'),
"kb details": grchatgpt.getValue('kb_introduction')
};
val.push(res);
}
response.setBody(val);
})(request, response);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 07:33 PM
Hi @Rushi2
getDisplayValue or getValue both gets you the HTML type field contents. But while passing it over the REST , it's better to escape the HTML.
Are you getting all the field values when you hit the actual API except the HTML fields? Or the API itself is not working?
Anvesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 07:38 PM
@Rushi2 Please use the updated code and see if it works for you.
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var val = [];
// implement resource here//
var grchatgpt = new GlideRecord('kb_knowledge');
grchatgpt.addEncodedQuery("workflow_state=published^kb_knowledge_base=100c36a80f115244272e244be1050e88");
grchatgpt.orderByDesc('sys_updated_on');
grchatgpt.query();
while (grchatgpt.next()) {
var abc = grchatgpt.kb_introduction.toString();
var res = {
"Number": grchatgpt.getValue('number'),
"knowledge base": grchatgpt.getDisplayValue('kb_knowledge_base'),
"valid to": grchatgpt.getValue('valid_to'),
"short description": grchatgpt.getValue('short_description'),
"Assignment group": grchatgpt.getDisplayValue('u_assignment_group'),
"Internal notes": grchatgpt.getValue('u_internal_notes'),
"kb instructions": grchatgpt.getValue('kb_instructions'),
"kb support details": grchatgpt.getValue('u_kb_support_details'),
"kb details": grchatgpt.getValue('kb_introduction')
};
val.push(res);
}
response.setBody(val);
})(request, response);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 08:42 AM
Hi Sandeep
Thank you so much for your response, Still, I am not getting HTML fields.
"kb instructions": null,
"kb support details": null,
"kb details": null

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2023 11:09 AM
@Rushi2 Can you confirm if the values for fields
kb_instructions, u_kb_support_details, kb_introduction
exist on the kb article? Can you log the sys_id of the kb articles and search them on the instance to check if these fields are actually having data on them?