Attachment on multiple tasks

sry
Giga Guru

Hi, i have a requirement where user needs to attach one document(pdf) on multiple tasks like around 100 incidents.

could anyone please help me!

thanks,

sry

1 ACCEPTED SOLUTION

Hello sry,

So, me recommendation is simple:

  • From those 100 incidents, manually attach the file to one of them
  • Go to the sys_attachment table, locate the file that you added, by filtering records where:
    • table name = incident
    • table sys id = your incident sys_id
  • Create a fix script with the following code:

    var orig_incident_id = "<sys_id of the incident where you added the attachment>";
    copyAtt(orig_incident_id);
    function copyAtt(orig_incident_id){
    	var gr = new GlideRecord("incident");
    	gr.addEncodedQuery("<add your query to pick the other 99 incidents");
    	gr.query();
    	var counter = 0;
    	while(gr.next()){
    		new GlideSysAttachment().copy("incident", orig_incident_id, "incident", gr.sys_id);
    		++counter;
    	}
    	gs.info("copied attachment to " + counter.toString() + " records");
    }​

     

This should do the trick!!

Please, if this answer is relevant for you, please mark it as correct and helpful.

Thanks,

Filipe

View solution in original post

6 REPLIES 6

Filipe Cruz
Kilo Sage
Kilo Sage

Hello,

May I ask what kind of attachment needs to be added to 100 incidents?

As a possible idea: does it make sense to create a knowledge article that will contain that attachment and then do a bulk update to relate the knowledge article to the attachment? 

Remember that in this way you are not generating 100 copies of the same file!

Let me know more about this!

Please, if this answer is relevant for you, please mark it as correct and helpful.

Thanks,

Filipe

Hi Filipe, thank you for prompt response.

 

i understand we are duplicating but the user insists he wants to attach same document on all defects.

i have considered KB route but they refused that route.

 

Thanks,

sry

Hi sry, Is that a one-time action or you need a solution for a daily basis usage?

Hi Felipe, this is a one time action i think. but i think if we have a solution we can use it for daily right!

thanks,

sry