Attaching the knowledge article from parent incident to child incident automatically
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 05:02 AM
Attaching the knowledge article from parent incident to child incident through script. But when i am creating new child incident Duplicate KB article is attaching. Please guide me why this is happening
(function executeRule(current, previous /*null when async*/) {
// // Add your code here
// if(current.task.sys_class_name == 'incident')
var parent = current.sys_id;
var inc = new GlideRecord('incident');
inc.addQuery('parent_incident', parent);
inc.query();
while(inc.next())
{
var kn1 = new GlideRecord('m2m_kb_task');
kn1.addQuery('task',kn1.task.p);
kn1.initialize();
kn1.task = inc.sys_id.toString();
kn1.kb_knowledge=current.u_ka_attached;
kn1.insert();
}
})(current, previous);
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 05:24 AM
Hello @Nafisa Zaman
Modify your script with mine :-
(function executeRule(current, previous /*null when async*/) {
// // Add your code here
// if(current.task.sys_class_name == 'incident')
var parent = current.sys_id;
var inc = new GlideRecord('incident');
inc.addQuery('parent_incident', parent);
inc.query();
while(inc.next())
{
var kn1 = new GlideRecord('m2m_kb_task');
kn1.addQuery('task',kn1.task.p);
kn1.initialize();
kn1.task = inc.sys_id.toString();
kn1.kb_knowledge=current.u_ka_attached;
kn1.insert();
var attach = new GlideSysAttachment();
attach.deleteAll(current.sys_id);
}
})(current, previous);
Plz mark my solution as Accept, If you find it helpful.
Regards,
Samaksh
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2023 06:32 AM
When i am going to create a new child in parent new child is created but in every child duplicate KA is coming.
i dont want duplicate KA attach to my child incident.