Name
sn_hr_sp.UserRecommendationUtilSNC
Description
No description available
Script
var UserRecommendationUtilSNC = Class.create();
UserRecommendationUtilSNC.prototype = {
initialize: function() {},
getKbGrFromSysId: function(articleId) {
var gr = new GlideRecord("kb_knowledge");
gr.get(articleId);
return gr;
},
/* getMostViewedArticles: Gets the most viewed articles based on view count of the articles
Parameters : 1)knowledgeBases : List of knowledge bases that are accessible for the portal in which the widget is placed
2)kbRecord : Article Record
3)articleCount : The number of articles to be returned
4)ignoreArticles : The list of articles to ignore. In User profile Recommendation if one result is fetched from ML, the other two are fetched from this method. In this case the ignore articles contains the sys_id of the article that is already been fetched from ML
*/
getMostViewedArticles: function(articlePayload) {
var versioningEnabled = GlidePluginManager.isActive('com.snc.knowledge_advanced') && gs.getProperty("glide.knowman.versioning.enabled", "true") === "true";
var isKnowledgeTranslationPluginActive = GlidePluginManager.isActive('com.glideapp.knowledge.i18n2');
var preferredLanguage = gs.getSession().getLanguage();
var fallBackLanguage = gs.getProperty('glide.sys.language');
var accessibleKbs = new sn_ex_sp.TopicSecurityUtil().fetchKnowledgeBaseFromSession();
var count = 0;
var articles = [];
var articleDetails = {};
if (!gs.nil(articlePayload.ignoreArticles))
articlePayload.kbRecords.addQuery('sys_id', 'NOT IN', articlePayload.ignoreArticles);
if (!gs.nil(articlePayload.taxonomyId)) {
articlePayload.kbRecords.addQuery('taxonomy_topic.taxonomy', articlePayload.taxonomyId);
}
articlePayload.kbRecords.addQuery('kb_knowledge_base', 'IN', accessibleKbs);
articlePayload.kbRecords.addQuery('sys_view_count', '>', '0');
if (isKnowledgeTranslationPluginActive) {
if (preferredLanguage != fallBackLanguage) {
var fallbackGr = new GlideRecord(articlePayload.kbRecords.getTableName());
fallbackGr.addEncodedQuery(articlePayload.kbRecords.getEncodedQuery());
}
articlePayload.kbRecords.addQuery('language', preferredLanguage);
}
articlePayload.kbRecords.orderByDesc('sys_view_count');
articlePayload.kbRecords.query();
while (articlePayload.kbRecords.next() && count < articlePayload.articleCount) {
articleDetails = {};
articleDetails = this.checkAndReturnAccessibleArticle(articlePayload.kbRecords.sys_id, articlePayload.knowledgeBases, versioningEnabled, articlePayload.taxonomyId);
if (!gs.nil(articleDetails) && !this.isArticleDuplicate(articles, articleDetails, articlePayload.ignoreArticles)) {
++count;
articleDetails.score = articlePayload.kbRecords.getValue('sys_view_count');
articleDetails.category = 'article';
articles.push(articleDetails);
}
}
if (count < articlePayload.articleCount && isKnowledgeTranslationPluginActive && preferredLanguage != fallBackLanguage) {
var consideredArticleIds = [];
articles.forEach(function(articleDetail) {
var translatedArticleId = this.getArticleInPreferredLanguage(this.getKbGrFromSysId(articleDetail.sys_id), fallBackLanguage);
if (translatedArticleId)
consideredArticleIds.push(translatedArticleId);
}, this);
fallbackGr.addQuery('language', fallBackLanguage);
fallbackGr.addQuery('sys_id', 'NOT IN', consideredArticleIds);
fallbackGr.orderByDesc('sys_view_count');
fallbackGr.query();
while (fallbackGr.next() && count < articlePayload.articleCount) {
articleDetails = this.checkAndReturnAccessibleArticle(fallbackGr.sys_id, articlePayload.knowledgeBases, versioningEnabled, articlePayload.taxonomyId);
if (!gs.nil(articleDetails) && !this.isArticleDuplicate(articles, articleDetails, articlePayload.ignoreArticles)) {
++count;
articleDetails.score = articlePayload.kbRecords.getValue('sys_view_count');
articleDetails.category = 'article';
articles.push(articleDetails);
}
}
}
return articles;
},
/* getArticlesforSimilarUsers : Gets the most viewed Articles of all the similar users based on the article usage recorded in kb_use table
Parameters: 1)users: List of similar users
2)knolwdgeBases : List of knowledge bases that are accessible for the portal in which the widget is placed
3)articleCount : Number of articles to be returned
*/
getArticlesforSimilarUsers: function(dataPayload) {
var versioningEnabled = GlidePluginManager.isActive('com.snc.knowledge_advanced') && gs.getProperty("glide.knowman.versioning.enabled", "true") === "true";
var isKnowledgeTranslationPluginActive = GlidePluginManager.isActive('com.glideapp.knowledge.i18n2');
var preferredLanguage = gs.getSession().getLanguage();
var fallBackLanguage = gs.getProperty('glide.sys.language');
var accessibleKbs = new sn_ex_sp.TopicSecurityUtil().fetchKnowledgeBaseFromSession();
var count = 0;
var articles = [];
var articleDetails = {};
var kbUse = new GlideAggregate('kb_use');
kbUse.addQuery('user', 'IN', dataPayload.users);
kbUse.addQuery('article.kb_knowledge_base', 'IN', accessibleKbs);
if (!gs.nil(dataPayload.recentActivityCutoffDate))
kbUse.addQuery('sys_created_on', '>=', dataPayload.recentActivityCutoffDate);
if (isKnowledgeTranslationPluginActive) {
if (preferredLanguage != fallBackLanguage) {
var fallBackKbUse = new GlideRecord(kbUse.getTableName());
fallBackKbUse.addEncodedQuery(kbUse.getEncodedQuery());
}
kbUse.addQuery('article.language', preferredLanguage);
}
kbUse.addAggregate('COUNT', 'article');
kbUse.orderByAggregate('COUNT', 'article');
kbUse.query();
while (kbUse.next() && count < dataPayload.articleCount) {
articleDetails = {};
articleDetails = this.checkAndReturnAccessibleArticle(kbUse.article, dataPayload.knowledgeBases, versioningEnabled, dataPayload.taxonomyId);
if (!gs.nil(articleDetails) && !this.isArticleDuplicate(articles, articleDetails)) {
++count;
articleDetails.score = kbUse.getAggregate('COUNT', 'article');
articleDetails.category = 'article';
articles.push(articleDetails);
}
}
if (count < dataPayload.articleCount && isKnowledgeTranslationPluginActive && preferredLanguage != fallBackLanguage) {
var consideredArticleIds = [];
articles.forEach(function(articleDetail) {
var translatedArticleId = this.getArticleInPreferredLanguage(this.getKbGrFromSysId(articleDetail.sys_id), fallBackLanguage);
if (translatedArticleId)
consideredArticleIds.push(translatedArticleId);
}, this);
fallBackKbUse.addQuery('article.language', fallBackLanguage);
fallBackKbUse.addQuery('sys_id', 'NOT IN', consideredArticleIds);
fallBackKbUse.orderByDesc('sys_view_count');
fallBackKbUse.query();
while (fallBackKbUse.next() && count < dataPayload.articleCount) {
articleDetails = this.checkAndReturnAccessibleArticle(fallBackKbUse.sys_id, dataPayload.knowledgeBases, versioningEnabled, dataPayload.taxonomyId);
if (!gs.nil(articleDetails) && !this.isArticleDuplicate(articles, articleDetails)) {
++count;
articleDetails.score = fallBackKbUse.getAggregate('COUNT', 'article');
articleDetails.category = 'article';
articles.push(articleDetails);
}
}
}
return articles;
},
/* checkAndReturnAccessibleArticle : Checks if the current user can access the article and returns the article details sysId and short_description
Parmeters : 1) articleId : sysId of the article
2) knolwdgeBases: List of knowledge bases that are accessible for the portal in which the widget is placed
3) versioningEnabled : True if com.snc.knowledge_advanced is intalled and also if glide.knowman.versioning.enabled property is true, to get the latest article if versioning is enabled
*/
checkAndReturnAccessibleArticle: function(articleId, knowledgeBases, versioningEnabled, taxonomyId) {
var article = {};
var articleGr = new GlideRecord('kb_knowledge');
if (!gs.nil(taxonomyId)) articleGr.addQuery('taxonomy_topic.taxonomy', taxonomyId);
articleGr.addQuery('sys_id', articleId);
new global.KBKnowledge().addKnowledgeQueries(articleGr, knowledgeBases, true);
articleGr.addQuery('workflow_state', 'IN', 'outdated,published');
articleGr.query();
if (articleGr.next() && articleGr.canRead()) {
if (versioningEnabled && articleGr.workflow_state != 'published') {
var grsKbLatest = new GlideRecord("kb_knowledge");
new global.KBKnowledge().addKnowledgeQueries(grsKbLatest, knowledgeBases, true);
grsKbLatest.addQuery('article_id', articleGr.article_id);
grsKbLatest.addQuery('workflow_state', 'published');
grsKbLatest.addQuery("sys_created_on", ">=", articleGr.sys_created_on);
grsKbLatest.orderByDesc('sys_created_on');
grsKbLatest.setLimit(1);
grsKbLatest.query();
if (grsKbLatest.next() && grsKbLatest.canRead()) {
article.short_description = grsKbLatest.getValue('short_description');
article.description = grsKbLatest.getValue('description');
article.sys_created_on = grsKbLatest.getValue('sys_created_on');
article.sys_updated_on = grsKbLatest.getValue('sys_updated_on');
article.meta_description = grsKbLatest.getValue('meta_description');
article.sys_id = grsKbLatest.getValue('sys_id');
} else
return null;
} else {
article.short_description = articleGr.getValue('short_description');
article.description = articleGr.getValue('description');
article.sys_id = articleGr.getValue('sys_id');
article.sys_created_on = articleGr.getValue('sys_created_on');
article.sys_updated_on = articleGr.getValue('sys_updated_on');
article.meta_description = articleGr.getValue('meta_description');
}
return article;
} else
return null;
},
/*getCatalogItems : Gets the list of most submmited catalog Items
Parameters : 1) users : List of similar users for the logged in users. If the list is not empty , only the catalog items submitted by the similar users are returned. If the list is empty catalog items submitted by all users are considered
2) catalogs : List of catalogs that are supported by the portal in which the widget is displayed
3) catalogCount : Number of catalog Items to be returned
4)ignoredCatalogs : The list of catalog items to ignore. In User Recommendation if one result is fetched from ML based on similar users, the other two are fetched from this method without considering similar users. In this case the ignore catalogs contains the sys_id of the catalog that is already been fetched from ML
*/
getCatalogItems: function(catalogData) {
var catItemArray = [];
// if there is no taxonomy assosiated then do not use m2m_connected_content
if (!gs.nil(catalogData.users) || !gs.nil(catalogData.recentActivityCutoffDate) || !gs.nil(catalogData.taxonomyId)) {
var portalCatalogs = [];
if (gs.nil(catalogData.taxonomyId)) {
portalCatalogs = $sp ? $sp.getCatalogs().value.split(',') : [];
}
var reqItems = this.getRequestItems(catalogData.users, catalogData.ignoredCatalogs, catalogData.catalogCount, catalogData.recentActivityCutoffDate, catalogData.taxonomyId, portalCatalogs);
var recordProducers = this.getRecordProducers(catalogData.users, catalogData.ignoredCatalogs, catalogData.catalogCount, catalogData.recentActivityCutoffDate, catalogData.taxonomyId, portalCatalogs);
var finalList = reqItems.concat(recordProducers);
finalList.sort(this._sortCatalog);
return finalList.slice(0, catalogData.catalogCount);
} else {
//get content from m2m table when ml/similar users not present, and recent activity cutoff date is not mentioned(configurable).(mobile scenario)
var allCatItems = this.getAllCatalogsFromConnectedContent(catalogData.ignoredCatalogs, catalogData.catalogCount, catalogData.taxonomyId);
allCatItems.sort(this._sortCatalog);
return allCatItems.slice(0, catalogData.catalogCount);
}
},
/*getRequestItems : Gets the list of catalog items submitted from sc_req_item table , which records the catalog items submitted by a user.Here in order to distinguish between each submission of catalog Item , the results are grouped based on Requested For and Catalog Item.
Parameters : 1) users : List of similar users for the logged in users. If the list is not empty , only the catalog items submitted by the similar users are returned. If the list is empty catalog items submitted by all users are considered
2)ignoredCatalogs : The list of catalog items to ignore.In User Recommendation if one result is fetched from ML based on similar users, the other two are fetched from this method without considering similar users. In this case the ignoreCatalogs contains the sys_id of the catalog that is already been fetched from ML
*/
getRequestItems: function(users, ignoredCatalogs, catalogCount, recentActivityCutoffDate, taxonomyId, portalCatalogs) {
var count = 0;
var result = [];
var catItem = {};
var catItemGr = new GlideRecord('sc_cat_item');
catItemGr.setCategory("catalog_meta");
if (!gs.nil(taxonomyId)) {
catItemGr.addQuery('taxonomy_topic.taxonomy', taxonomyId);
catItemGr.addQuery('taxonomy_topic.active', true);
} else if(portalCatalogs && portalCatalogs.length > 0) {
var catalogsQuery = '';
portalCatalogs.forEach(function(catalog){
catalogsQuery = catalogsQuery + (catalogsQuery ? '^OR' : '') + 'sc_catalogsCONTAINS' + catalog ;
});
catItemGr.addEncodedQuery(catalogsQuery);
}
catItemGr.addQuery('active', true);
catItemGr.addQuery('visible_standalone', 'true');
catItemGr.addEncodedQuery('hide_sp=false^ORhide_spISEMPTY');
catItemGr.query();
var catalogIds = [];
while (catItemGr.next()) {
catalogIds.push(catItemGr.getUniqueValue());
}
var reqItems = new GlideAggregate('sc_req_item');
reqItems.setCategory("catalog_meta");
if (!gs.nil(users))
reqItems.addQuery('request.requested_for', 'IN', users);
if (!gs.nil(ignoredCatalogs))
reqItems.addQuery('cat_item', 'NOT IN', ignoredCatalogs);
/*Order guides are fetched seperately in getOrderGuides function */
reqItems.addNullQuery('order_guide');
reqItems.addQuery('cat_item', 'IN', catalogIds);
reqItems.addQuery('sys_created_on', '>=', recentActivityCutoffDate);
reqItems.addAggregate('COUNT', 'cat_item');
reqItems.orderByAggregate('COUNT', 'cat_item');
reqItems.query();
while (reqItems.next() && count < catalogCount) {
catItem = {};
catItem.sys_id = reqItems.getValue('cat_item');
catItem.count = reqItems.getAggregate('COUNT', 'cat_item');
catItem.score = parseInt(catItem.count);
catItem.category = "catalog";
var catalogItemJS = new sn_sc.CatItem(catItem.sys_id);
if (!GlideappCatalogItem.get(catItem.sys_id).canView() || !catalogItemJS.canView(gs.isMobile()) || !catalogItemJS.isVisibleServicePortal())
continue;
var catalogItemDetails = catalogItemJS.getItemSummary(true, "basic");
catItem.short_description = catalogItemDetails.short_description;
catItem.name = catalogItemDetails.name;
catItem.href = "?id=sc_cat_item&sys_id=" + catalogItemDetails.sys_id;
catItem.icon = catalogItemDetails.icon;
catItem.image = catalogItemDetails.picture;
catItem.price = this.checkItemPrice(reqItems.cat_item);
var recurring_frequency = reqItems.cat_item.recurring_frequency;
var recurring_price = reqItems.cat_item.recurring_price.getDisplayValue();
var zeroRecurringPriceVal = '0.00';
var isRecurringPriceNonZero = recurring_price && recurring_price.substr(1, 4) !== zeroRecurringPriceVal;
if (recurring_frequency && isRecurringPriceNonZero)
catItem.price = catItem.price + ' + ' + recurring_price + '/' + recurring_frequency;
result.push(catItem);
++count;
}
return result;
},
/*getRecordProducers: Gets the list of Record Producers submitted from sc_item_produced_record , which records the record producer submitted by a user.Here in order to distinguish between each submission of Record Producer ,the results are grouped based on Created by and Producer.
Parameters : 1) users : List of similar users for the logged in users. If the list is not empty , only the catalog items submitted by the similar users are returned. If the list is empty catalog items submitted by all users are considered
2)ignoredCatalogs : The list of catalog items to ignore. In User Recommendation if one result is fetched from ML based on similar users, the other two are fetched from this method without considering similar users. In this case the ignoreCatalogs contains the sys_id of the catalog that is already been fetched from ML
*/
getRecordProducers: function(users, ignoredCatalogs, catalogCount, recentActivityCutoffDate, taxonomyId, portalCatalogs) {
var count = 0;
var producer = {};
var result = [];
var userId = [];
var reqItems = new GlideAggregate('sc_item_produced_record');
reqItems.setCategory("catalog_meta");
if (!gs.nil(taxonomyId)) {
reqItems.addQuery('producer.taxonomy_topic.taxonomy', taxonomyId);
reqItems.addQuery('producer.taxonomy_topic.active', true);
} else if(portalCatalogs && portalCatalogs.length > 0) {
var catalogsQuery = '';
portalCatalogs.forEach(function(catalog){
catalogsQuery = catalogsQuery + (catalogsQuery ? '^OR' : '') + 'producer.sc_catalogsCONTAINS' + catalog ;
});
reqItems.addEncodedQuery(catalogsQuery);
}
if (!gs.nil(users))
reqItems.addQuery('task.opened_by', 'IN', users);
if (!gs.nil(ignoredCatalogs))
reqItems.addQuery('producer', 'NOT IN', ignoredCatalogs);
reqItems.addQuery('producer.active', true);
reqItems.addQuery('sys_created_on', '>=', recentActivityCutoffDate);
reqItems.addQuery('producer.visible_standalone', 'true');
reqItems.addEncodedQuery('producer.hide_sp=false^ORproducer.hide_spISEMPTY');
reqItems.addAggregate('COUNT', 'producer');
reqItems.orderByAggregate('COUNT', 'producer');
reqItems.query();
while (reqItems.next() && count < catalogCount) {
producer = {};
producer.sys_id = reqItems.getValue('producer');
producer.count = reqItems.getAggregate('COUNT', 'producer');
producer.score = parseInt(producer.count);
producer.category = "catalog";
var catalogItemJS = new sn_sc.CatItem(producer.sys_id);
if (!GlideappCatalogItem.get(producer.sys_id).canView() || !catalogItemJS.canView(gs.isMobile()) || !catalogItemJS.isVisibleServicePortal())
continue;
var catalogItemDetails = catalogItemJS.getItemSummary(true, "basic");
producer.short_description = catalogItemDetails.short_description;
producer.name = catalogItemDetails.name;
producer.href = "?id=sc_cat_item&sys_id=" + catalogItemDetails.sys_id;
producer.icon = catalogItemDetails.icon;
producer.image = catalogItemDetails.picture;
producer.price = this.checkItemPrice(reqItems.producer);
var recurring_frequency = reqItems.producer.recurring_frequency;
var recurring_price = reqItems.producer.recurring_price.getDisplayValue();
var zeroRecurringPriceVal = '0.00';
var isRecurringPriceNonZero = recurring_price && recurring_price.substr(1, 4) !== zeroRecurringPriceVal;
if (recurring_frequency && isRecurringPriceNonZero)
producer.price = producer.price + ' + ' + recurring_price + '/' + recurring_frequency;
result.push(producer);
++count;
}
return result;
},
getAllCatalogsFromConnectedContent: function(ignoredCatalogs, catalogCount, taxonomyId) {
var producer = {};
var result = [];
var m2mGr = new GlideAggregate('m2m_connected_content');
m2mGr.addQuery('topic.taxonomy', taxonomyId);
m2mGr.addQuery('topic.active', true);
m2mGr.addQuery('content_type.name', 'Catalog Item');
if (!gs.nil(ignoredCatalogs))
m2mGr.addQuery('catalog_item', 'NOT IN', ignoredCatalogs);
m2mGr.addAggregate('COUNT', 'catalog_item');
m2mGr.orderByDesc('popularity');
m2mGr.orderBy('catalog_item');
m2mGr.orderBy('catalog_item.name');
m2mGr.setLimit(catalogCount);
m2mGr.query();
while (m2mGr.next()) {
producer = {};
producer.sys_id = m2mGr.getValue('catalog_item');
producer.count = m2mGr.popularity;
producer.score = parseInt(m2mGr.popularity);
producer.category = "catalog";
var catalogItemJSM2M = new sn_sc.CatItem(producer.sys_id);
if (!GlideappCatalogItem.get(producer.sys_id).canView() || !catalogItemJSM2M.canView(gs.isMobile()) || !catalogItemJSM2M.isVisibleServicePortal())
continue;
var catalogItemDetailsM2M = catalogItemJSM2M.getItemSummary(true, "basic");
producer.short_description = catalogItemDetailsM2M.short_description;
producer.name = catalogItemDetailsM2M.name;
producer.href = "?id=sc_cat_item&sys_id=" + catalogItemDetailsM2M.sys_id;
producer.icon = catalogItemDetailsM2M.icon;
producer.image = catalogItemDetailsM2M.picture;
producer.price = this.checkItemPrice(m2mGr.catalog_item);
var recurring_frequency = m2mGr.catalog_item.recurring_frequency;
var recurring_price = m2mGr.catalog_item.recurring_price.getDisplayValue();
var zeroRecurringPriceVal = '0.00';
var isRecurringPriceNonZero = recurring_price && recurring_price.substr(1, 4) !== zeroRecurringPriceVal;
if (recurring_frequency && isRecurringPriceNonZero)
producer.price = producer.price + ' + ' + recurring_price + '/' + recurring_frequency;
result.push(producer);
}
return result;
},
_sortCatalog: function(a, b) {
return b.count - a.count;
},
checkItemPrice: function(catItem) {
if (catItem.price == 0 || catItem.price == null || catItem.price == undefined) {
return null;
} else {
return catItem.price.getDisplayValue();
}
},
/*calculateNormalizedScore : Calculates the Normalization score based on the data provided
Parameters : 1) dataArr : Array of items (catalog or kb Articles) to get the zScore from
*/
getZScore: function(dataArr) {
if (dataArr.length == 0)
return dataArr;
var minScore = 0;
var maxScore = 100;
var max = dataArr[0];
var min = dataArr[dataArr.length - 1];
if (max == min) {
dataArr[0].zScore = maxScore;
return dataArr;
}
var articleSum = 0;
dataArr.forEach(function(article) {
articleSum = articleSum + parseInt(article.score);
});
var articlesMean = articleSum / dataArr.length;
var sdSum = 0;
dataArr.forEach(function(article) {
sdSum = sdSum + Math.pow((article.score - articlesMean), 2);
});
var standardDeviation = Math.sqrt(sdSum / (dataArr.length - 1));
dataArr.forEach(function(item) {
item.zScore = (item.score - articlesMean) / standardDeviation;
});
return dataArr;
},
/*getNormalizedData : Gets the Normalized data after calculating the zScores
Parameters : 1) combinedData : An array of the most viewed kb articles and Catalog Items combined or individual data
3) isMixed: Specifies if the combined data is individual (article data or item data) or combined data
*/
getNormalizedData: function(combinedData, displayCount, isMixed) {
if (isMixed) {
articleResults = combinedData.articleResults.length > 0 ? this.getZScore(combinedData.articleResults) : [];
catalogResults = combinedData.catalogResults.length > 0 ? this.getZScore(combinedData.catalogResults) : [];
var x = articleResults[0];
var y = catalogResults[0];
return articleResults.concat(combinedData.catalogResults).sort(function(a, b) {
return b.zScore - a.zScore;
}).slice(0, displayCount);
} else return this.getZScore(combinedData).sort(function(a, b) {
return b.zScore - a.zScore;
}).slice(0, displayCount);
},
/*getTranslatedArticle: returns a valid articleId based on the User Preffered Language / Fallback language
Parameters: 1) articleId : sys id of the KB
2) preferredLanguage: User preferred language
3) fallBackLanguge: System Fallback Language
*/
getTranslatedArticle: function(articleId, preferredLanguage, fallBackLanguage) {
var articleGr = new sn_ex_sp.KBContentTranslationUtil().getKbGr(articleId);
if (articleGr) {
var preferredArticleId = this.getArticleInPreferredLanguage(articleGr, preferredLanguage);
if (!gs.nil(preferredArticleId)) {
return preferredArticleId;
} else {
return this.getArticleInPreferredLanguage(articleGr, fallBackLanguage);
}
}
return null;
},
/*getArticleInPreferredLanguage: returns articleId / null if present in language
Parameters: 1) articleGr: article GlideRecord
2) langugage: preferred Language
*/
getArticleInPreferredLanguage: function(articleGr, langugage) {
if (articleGr.getValue('language') === langugage) {
return articleGr.getUniqueValue();
}
var translatedGr = new sn_ex_sp.KBContentTranslationUtil().getTranslatedVersionsFromGr(articleGr, langugage);
if (translatedGr.next() && translatedGr.getValue('workflow_state') === 'published') {
return translatedGr.getUniqueValue();
}
return null;
},
/*isArticleDuplicate: returns true / false based on object already part of array
Parameters: 1) articleArray : article Array
2) currentArticle: current Article Object
3) ignoredArticle: ignore Artilces Array
*/
isArticleDuplicate: function(articleArray, currentArticle, ignoreArticles) {
if (!gs.nil(ignoreArticles)) {
if (ignoreArticles.indexOf(currentArticle.sys_id) !== -1) {
return true;
}
}
return articleArray.some(function(element) {
return element.sys_id === currentArticle.sys_id;
});
},
type: 'UserRecommendationUtilSNC'
};
Sys ID
94d06ee7db3b04509dd29207db961953