KBPortalServiceImpl - グローバル
KBPortalServiceImpl API は、Knowledge Management V3 [com.snc.knowledge3] にスクリプトインクルードとして含まれています。カスタム検索とのデータ連携など、ナレッジとともに使用するためのメソッドを提供します。
KBPortalServiceImpl - KBPortalServiceImpl()
グローバル アプリケーションで KBPortalServiceImpl オブジェクトをインスタンス化します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
KBPortalServiceImpl - getResultData(Object request)
ナレッジ記事およびユーザーに読込可能アクセス権限がある関連ナレッジからのキーワードに基づいて、検索結果を戻します。
ナレッジ ブロック機能を有効にし、アプリケーションに関するナレッジのカスタム検索を使用している場合、キーワードがブロックに含まれていると、関連する記事が戻されないことがあります。記事およびユーザーに読込可能アクセス権限がある関連ブロック コンテンツからのキーワードに基づいて検索結果を戻すためには、getResultData() メソッドをカスタム検索内で呼び出す必要があります。
| 名前 | タイプ | 説明 |
|---|---|---|
| 要求 | オブジェクト | 検索を絞り込む JSON オブジェクト。 |
| タイプ | 説明 |
|---|---|
| オブジェクト | ナレッジ記事およびユーザーに読込可能アクセス権限がある関連ナレッジ ブロック コンテンツからのキーワードに基づく JSON 形式での検索結果の配列。 |
カスタム検索のナレッジ ブロックへのデータ連携
function doKeywordSearch(queryText, count, queryLocation) {
var results = [];
// To set up the request.
var request = {
keyword: queryText,
language: "",
// To pass data to filter on different metadata.
variables: {
kb_knowledge_base: ['Knowledge'],
kb_category: '',
author: ['']
},
// Provide the following.
context: gs.getProperty('glide.knowman.sp.search_context', 'Knowledge Search'),
resource: 'Knowledge',
order: "relevancy,true",
// Provide the pagination variables.
start: queryLocation,
end: queryLocation+count,
attachment: false,
// Provide any additional metadata you want to include in your results.
knowledge_fields: [
"number",
"sys_id",
"published"
]
};
// To execute the search.
var response = new KBPortalServiceImpl();
response.getResultData(request);
// To send the search results back to the UI or to store results in your object.
for (var i = 0; i < response.results.length; i++) {
result = response.results[i];
var article = {};
article.sys_id = result.meta.sys_id.display_value;
article.number = result.meta.number.display_value;
article.short_description = article.short_description;
article.title = result.title;
article.published = result.meta.published.display_value;
article.publishedUTC = result.meta.published.display_value;
article.text = article.text;
article.score = result.meta.score;
article.label = article.short_description;
article.shortDescription = article.short_description;
results.push(article);
}
return results;
}