- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 01:14 AM
Hi,
Need to copy email activities from incident to related problem record.
Can you please anyone help me.
Thanks in Advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 05:27 AM
Hi @mania ,
I see you are triggering mails based on state as closed, resolved. So I tried to copy the work notes on related problem according to that. If it is so you can use the below code and modify as per your requirement. (Find ss attached)
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var prblm = current.problem_id;
var state = current.getDisplayValue('state');
var prvState = previous.getDisplayValue('state');
var code = current.close_code;
var notes = current.close_notes;
var workNote = "[code]<b>Incident State </b>[/code]" +state+' was '+prvState +'\n'+' [code]<b>Resolution Code </b>[/code] '+code+'\n'+' [code]<b>Resolution Notes </b>[/code] '+notes;
var prblmGr = new GlideRecord('problem');
prblmGr.addQuery('sys_id',prblm);
prblmGr.query();
if(prblmGr.next()){
prblmGr.work_notes=workNote;
prblmGr.update();
}
})(current, previous);
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Mayur Shardul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 06:26 AM
Hi @mania ,
You can add condition in code if the any of the field is empty you can ignore it.
Regards,
Mayur Shardul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 03:21 AM
Hi @mania ,
This email will get captured in sys_email table from activities of incident you cant copy it directly on problem. You can use sys_email table and can get incident record from there & copy same email details on related problem record. You can utilize business rule on insert of record on sys_email and subject contains incident filter.
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Mayur Shardul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 02:56 AM
Hi @mania ,
Once any email activity action happens on any table a record gets created in sys_history_line table for activities (in set field you can find specific record).
You can use those details and can create business rule to copy those from incident to problem.
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Mayur Shardul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 02:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 05:27 AM
Hi @mania ,
I see you are triggering mails based on state as closed, resolved. So I tried to copy the work notes on related problem according to that. If it is so you can use the below code and modify as per your requirement. (Find ss attached)
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var prblm = current.problem_id;
var state = current.getDisplayValue('state');
var prvState = previous.getDisplayValue('state');
var code = current.close_code;
var notes = current.close_notes;
var workNote = "[code]<b>Incident State </b>[/code]" +state+' was '+prvState +'\n'+' [code]<b>Resolution Code </b>[/code] '+code+'\n'+' [code]<b>Resolution Notes </b>[/code] '+notes;
var prblmGr = new GlideRecord('problem');
prblmGr.addQuery('sys_id',prblm);
prblmGr.query();
if(prblmGr.next()){
prblmGr.work_notes=workNote;
prblmGr.update();
}
})(current, previous);
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Mayur Shardul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 06:21 AM
Used your code its working but i have shared the screenshots of problem record their i can see empty resolution code and resolution notes. Is there any way to restrict this code to show only the data which is not empty.
Using the code which you provided am getting all the fields whichever is mentioned in the code, but I don't want empty values to be copied from incident activities to problem activities.
Thanks!
Mania
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 06:26 AM
Hi @mania ,
You can add condition in code if the any of the field is empty you can ignore it.
Regards,
Mayur Shardul