Adding task attachments to parent case

Rob Sestito
Mega Sage

Hey Comm!

I have a simple task that I am trying to accomplish. I am blanking on the route to take for what I need.

I currently have a UI Action 'Grab Attachments' on the HR Task Table. Simply, it copies the parent attachments and posts them to the Task. I want to create the same scenario, only the other way. I want another UI Acton on the HR Case table, to copy the child task attachments when needed.

Here is what I have for the HR Task table UI:

find_real_file.png

GlideSysAttachment.copy(current.parent.sys_class_name, current.parent, current.getTableName(), current.sys_id);

current.update();
action.setRedirectURL(current);

gs.addInfoMessage("Attachments have been added!");

gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');

First, I thought I could change change the GlideSysAttachment.copy line to state child / task. But I was wrong - I am sure this is simple, but I am unable to accomplish the simple right now. Can someone lend a hand?

Thank you!

-Rob

1 ACCEPTED SOLUTION

Rob Sestito
Mega Sage

Thanks again everyone!

We are going to take a different route. Users want to be able to email HR Task Attachments in an easier way. In a way that allows them to select which attachments to email. I have a good process for that on the HR Case table - so I am going to recreate that on the HR Task table.

 

Cheers!

-Rob

View solution in original post

9 REPLIES 9

Christian Prob2
Tera Guru

Hi Rob - I am not technical enough to give you a ready-made solution, but you are looking at a 1-many situation.

While a task has exactly one parent case (and it's easy to navigate that way) the other way 'round you could have multiple child tasks. So assuming you would want to to copy the attachments from all of them you'd need to build a list of all tasks that have the case as parent, then process each element in that list and copy the attachments (if existing) up to the parent. Voila!

(No you just need someone to write a working script for that) 😉 

Hey Christian,

That was a great call-out for sure! And it totally makes sense - but we as an org very rarely will have multiple tasks attached to a parent case. Oddly enough, my upper management do not like tasks. But that could come from a place of not fully understanding how to use them.

Thank you for the reply and call-out as it is a good catch.

But it is something I won't have to worry about with this.

Cheers!

-Rob

So.. not sure I read in between your lines correctly, but I think - even if you don;t have multiple tasks - you still need to use the approach from a technical point of view. The parent case 'does not know' who it's children are (or even if there are any), hence you need to query that and even if that query will in your context always come back with no or a max of one entries, that is the way to go.

Oooh - I see what you mean now.

That totally makes sense!

Thank you,

-Rob