Copy Attachment with out duplicates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2014 06:45 AM
Hi All,
I am trying to copy attachment from task table to request with out duplicates
can any one help me
thanks in advance
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2015 03:03 PM
I got it all working!! In addition to the attachment links not working, I realized it was also showing ALL Task attachments on ALL Cases. I'll post the final update of the design tomorrow. Thankfully, everything is tested and working.
Thank you very much for your patience and help. I really appreciate it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 01:17 AM
Hi shane,
I was able to get this working for me. However, its showing ALL Task attachments on ALL cases. You mentioned that you were able to fix it. Please help me with e full design or post it here. Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2017 07:05 AM
Prashant - Please try the below and see if it works as I don't recall what exactly made that piece work. This is what I have in Production.
FULL DESIGN:
Related List
System Definition > Relationships
Name: HR Task Attachments
Applies to table: HR Case [hr_case]
Queries from table: Attachment [sys_attachment]
(function() {
var csfam = commaSeparatedTaskFamily('hr_case',parent.sys_id); //in relationships the parent is whatever is displaying this list
var famarray = csfam.split(',');
var hgr = current.addQuery('table_sys_id',famarray[0]); //first record's attachments
for (var i=1; i<famarray.length; i++){
hgr.addOrCondition('table_sys_id',famarray[i]); //then gets the rest
}
})();
Script Include:
Name: commaSeparatedTaskFamily
Accessible from: All application scopes
function commaSeparatedTaskFamily(fromtable, recid){
var family = '';
//first has to find sys_id of target parent
/*if (fromtable == 'hr_task'){
var gr = new GlideRecord('hr_task');
gr.get(recid);
family = gr.parent; //gets parent's sys_id since its a reference
}*/
if (fromtable == 'hr_case'){
family = recid; //itself is the parent
}
/* if (fromtable == 'sysapproval_approver'){
var gr = new GlideRecord('sysapproval_approver');
gr.get(recid);
family = gr.sysapproval; //gets the approval_for's sys_id since its a reference
}*/
var ngr = new GlideRecord('hr_task');
ngr.addQuery('parent',family);
ngr.orderByDesc('number');
ngr.query();
while (ngr.next()){
family += ',';
family += ngr.sys_id;
}
return family;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2017 12:14 AM
Hi Shane,
Thanks for the code. I was able to reach this far, and it looks pretty good so far.
However, my requirement is:
I have an Incident, which has bunch of Incident_tasks. These incident_tasks has some attachments, and I am trying to reference them to Parent incident. I have created "Related Incident_tasks attachment" related list, and the list is showing all attachments which are not event related to these Incident tasks or its parent incident. I need to strict it to just show attachment on Incident record for its child incidents_tasks only.
Regards,
Prashant Rakesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2017 04:17 AM
Thanks. I did some more tweakings around and was able to get this worked for me.
Regards,
Prashant Rakesh