- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 03:29 AM
Hi Guys,
I'm doing an business rule on "after" , insert on Kb_knowledge Table, when a new KB is created I need to write a new record on m2m_connected_content, because I need to attach a kb to the current topic on employee( topic and kb_base have the same name). From the log i retrieve correctly the variables, but the record didn't created on m2m and i have this error : " ErrorContent can not be associated to the same topic more than once. "
Here the Code of my Business rule:
(function executeRule(current, previous /*null when async*/ ) {
gs.log("m2m_connectedINIZIO");
/***********************************/
var knowledgeBaseName = current.kb_knowledge_base.getDisplayValue();
var knowledgeBaseId = current.kb_knowledge_base.sys_id;
var topicGR = new GlideRecord('topic');
topicGR.addQuery('name', knowledgeBaseName);
//topicGR.addQuery('sys_id', knowledgeBaseId);
topicGR.query();
gs.log("m2mQuery " + topicGR.addQuery('name', knowledgeBaseName));
gs.log("m2mQueryID " + topicGR.addQuery('sys_id', knowledgeBaseId));
if (topicGR.next()) {
var topicName = topicGR.name;
var topicSysId = topicGR.sys_id;
}
gs.log("m2mTopicNAME: " + topicName); //ok
gs.log("m2mTopicSYSID: " + topicSysId); //ok
if (topicGR.isValid()) {
var m2mGR = new GlideRecord('m2m_connected_content');
m2mGR.initialize();
//m2mGR.newRecord();
m2mGR.topic = topicSysId;
m2mGR.content_type = '4c32a92153622010069addeeff7b12a3';
m2mGR.knowledge = knowledgeBaseId;
m2mGR.insert();
gs.info("Nuovo record inserito in m2m_connected_content");
gs.log("m2mASSEGNATOPIC: " + m2mGR.topic); //Ok
gs.log("m2mKnowledge: " + m2mGR.knowledge); //Ok
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 04:02 AM
You can associate content from multiple knowledge categories to a topic in the taxonomy.
Refer below docs link -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 03:58 AM
Dear @Chetan Mahajan & @Manmohan K ,
Thank you for your answer, the code is work fine, the problem is i can't add more knowledge to the topic, just one for each. This is a normal behavior of ServiceNow, or the problem was the script ? Maybe i can try NewRecord() than initialize() ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 04:02 AM
You can associate content from multiple knowledge categories to a topic in the taxonomy.
Refer below docs link -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 05:24 AM
I have fixed the issue , was a wrong mapping of
m2mGR.knowledge = knowledgeBaseId;
here needed to mapping the knoledge's number.
Thanks everyone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 05:08 AM
Hi Dario,
We had the same problem and changed it to current.number but it does not work still we have this:
Any idea why?
Thank you.
Best,
Firat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 05:29 AM
Hi mfaciahmetoglu,
can you post the code of BR and is before or after ?
Thank you