I want to automatically create knowledge articles in the inbound Email flow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 02:55 AM
I would like to accomplish the following three things, but am not familiar with scripting.
I receive an email and would like to compile a series of events into a single Knowledge article.
1. I want to extract the query number from the subject line of the email.
2. We want to update the Knowledge Article with the matching query number and add the body of the email.
3. We want to include an attachment attached to the e-mail in the Knowledge Article.
â–½Script #1
var shortDesc = fd_data.trigger.current.short_description;
strLength = shortDesc.length();
cutLength = 27;
str_id = shortDesc.substring(strLength - cutLength);
return str_id;
Best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 03:19 AM
Hello @A_13
Want to confirm fallowing things:
1)Do you want to create new knowledge article for query number or need to update existing knowledge article that matches with query number getting from subject line.
2)You can achieve the same by using inbound action.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 05:59 PM
Hello Mayuri
1)I need to update existing knowledge article that matches with query number getting from subject line.
2)Thank you. I will try the inbound action as well.
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2022 10:50 AM
Hello @A_13
You can try below solution to achieve first 2 points of your requirement. (tested on PDI)
1)As you want to extract query no from subject line , your subjects line format needs to be static (only query no. can be different).
2) So for example I kept my subject line as - Query no:KB0010022
3)Create new inbound action on "kb_knowledge" table.
4)Use below script in action section.
Splitting of subject line depends upon subject line format.
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var email_text = email.body_html.toString(); //storing body of email
gs.info("body is:" + email_text);
var subject = email.subject.split('Query No:'); // querying query no. from subject line
var subjectCI = subject[1];
gs.info("sub is:" + subjectCI);
//fetching knowledge article which matches query no. from subject line
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('number', subjectCI);
gr.query();
gs.info("count=" + gr.getRowCount();
if (gr.next()) {
gr.text = email_text; // updating article body with email body
gr.update();
}
})(current, event, email, logger, classifier);
Let mi know if any queries.
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
Thanks!