Need to copy email activities from incident to related problem record.

mania
Tera Contributor

Hi,

 

Need to copy email activities from incident to related problem record.

 

Can you please anyone help me.

mania_0-1695197631636.png

 

Thanks in Advance!

3 ACCEPTED SOLUTIONS

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

View solution in original post

Hi @mania ,

You can add condition in code if the any of the field is empty you can ignore it.

 

Regards,

Mayur Shardul

View solution in original post

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

View solution in original post

13 REPLIES 13

mania
Tera Contributor

Hi @Mayur2109 ,

 

Its working, but I have one doubt I want to copy emails to be received from incident activities to problem activities. 

Can you please help me out this case.

Attached screenshot for your reference.

mania_0-1695290056539.png

Thanks!

Mania

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

anshul_goyal
Kilo Sage

Hi @mania,

Please refer to the below link for your requirement: 

https://www.servicenow.com/community/itom-forum/how-to-copy-activity-log-from-incident-to-problem/m-...

I hope this will help you solve your problem. Please mark it as Accepted and Helpful.

Thanks and Regards
Anshul

Chetan Mahajan
Kilo Sage
Kilo Sage

@mania,

                 Follow this thread it might help you How to copy sent/received emails from incident record to a record in another table 

Kindly mark correct and helpful if applicable