Attachment uploaded in a task should be available in the next 2 tasks in a catalog item.

amogh_b6
Tera Expert

Hi @Ankur Bawiskar , we have a catalog item workflow in which we have 3 catalog tasks which are one after the other in the flow. So, we have a requirement that any attachment uploaded in task 1 should be available in task 2 and 3 as well.

 

For example: if any user submits the form and fulfiller attaches a document in the task 1 and closes the task, then this same document should be available/uploaded in task 2 and 3 as well.  

 

 

 

10 REPLIES 10

Hi Ankur,

 

We have not yet tried the script, we were figuring out whether to go with the workflow or the business rule. As per your suggestion, we will try a script and update you.

 

Thanks,

Amogh.

Anubhav24
Mega Sage

Hi @amogh_b6 ,

You can refer below URL to copy attachments on same table from one record to another. You can use this script in your catalog task script section

Please mark helpful/correct if my response helped you.

Hi Anubhav,

 

Could you please share that URL?

 

Thanks,

Amogh.

https://www.youtube.com/watch?v=bA-lvIFrkcU 

Sorry I missed out on giving the URL 

Instead of directly giving out the sysid you can use in your catalog task script task.sys_id.

Danish Bhairag2
Tera Sage

Hi @amogh_b6 ,

 

U can create a after insert BR with below condition:

DanishBhairag2_0-1698752366221.png

Here the idea is that the BR will only run in case of 2nd & 3rd Task creation. So u need to give proper item name by dot walking & short description of 1st task so that it does not run in that scenario.

 

In Advanced section u can run below script.(Please modify as per your requirement)

 

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here

    var task1 = new GlideRecord('sc_task');
    task1.addQuery('request_item', current.request_item);
    task1.addQuery('short_description', 'Enter shortdescription for task 1');
    task1.query();
    if (task1.query()) {
        var gr = new GlideRecord('sys_attachment');
        gr.addQuery('table_sys_id', task1.sys_id);
        gr.query();
        if (gr.next()) {
            var copyAtt = new GlideSysAttachment();
            copyAtt.copy('sc_task', task1.sys_id, 'sc_task', current.sys_id);
        }

    }



})(current, previous);

 

Thanks,

Danish