Copy attachments from RITM to Catalog Task and vice versa

Sampath8
Giga Expert

Hi Team,

I need a way to copy attachments from Ritm to Task and from Task to Ritm.

I am able to achieve, copying of attachments from Task to Ritm by using a business rule. But I also need to copy attachments from Ritm to Task without any duplicates.

Could any one help me in resolving the Task.

Let me know if I need to provide any other details.

Thanks in advance.

Regards,

Sampath.

1 ACCEPTED SOLUTION

Vimal Priya
Giga Guru

Hi Sampath,



I also had the same requirement.TASK to RITM is achievable because child-parent relationship .



We faced some problems in attachment so that instead of adding attachment RITM to catalog TASK ,I acheived it with the relationship (Created a related list on Catalog TASK table).


find_real_file.png


View solution in original post

8 REPLIES 8

gupta_vipul013
Mega Expert

Hi Sampath,



Yes, you can achieve the same with the help of async business rule on Attachment [sys_attachment] OR Request Item [sc_req_item] table. To copy the attachment, use the below code:



First, get the sys_id of the attachment, you wanted to copy to task table or vice versa.



var gr_atch = new GlideRecord('sys_attachment');


  gr_atch.get('fc4e0d41db08430038d7fd131d96193b');   // Attachment sys_id


 


  var gr_atch_new = new GlideRecord('sys_attachment');


  gr_atch_new.initialize();


  gr_atch_new.compressed = gr_atch.compressed;  


  gr_atch_new.content_type = gr_atch.content_type;  


  gr_atch_new.size_bites = gr_atch.size_bites;  


  gr_atch_new.size_compressed = gr_atch.size_compressed;  


  gr_atch_new.file_name = gr_atch.file_name;  


  gr_atch_new.table_name = 'sys_email';         //target table name


  gr_atch_new.table_sys_id = current.getValue('email');     // target table sys id


  var newID = gr_atch_new.insert();



Please, let me know, if you have any query related to the above code.



Regards,


Vipul


Vimal Priya
Giga Guru

Hi Sampath,



I also had the same requirement.TASK to RITM is achievable because child-parent relationship .



We faced some problems in attachment so that instead of adding attachment RITM to catalog TASK ,I acheived it with the relationship (Created a related list on Catalog TASK table).


find_real_file.png


Thanks for your quick response VimalPriya.


This worked really great



Thanks,


Sampath.


Hello How to limit this to only one catalog item?