How to Check if an attachment has been added by agent

sanvi
Tera Expert

Hi All,

 

I have a requirement to check "If an attachment has been added by an agent(Assigned To) user to a case " if yes then trigger the notification.

Can someone help with this.

 

7 REPLIES 7

@sanvi 

try this and it will check if attachment created by is not equal to case assigned to

var erCase = new GlideRecord('sn_hr_er_case');
    if (erCase.get(current.table_sys_id) && current.sys_created_by != erCase.assigned_to.user_name.toString()) {
     gs.eventQueue('sn_hr_er.add_attachment', erCase, current.file_name);
 }

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @sanvi , In your original post, it is written that event will be triggered if attachment is added by assigned to. Now try this, 
By below code, event will be triggered if attachment is added but not added by assigned to, try

 var caseGR = new GlideRecord('sn_hr_er_case');
    if (!caseGR.get(current.table_sys_id)) {
        return;
    }
	
    if (caseGR.assigned_to.user_name.toString() != current.sys_created_by.toString()) {
        //this condition will check if attachment is not added by assigned_to
        gs.eventQueue('sn_hr_er.add_attachment', erCase, current.file_name);
       
    }

And Mark the response as helpul/correct if i could help you.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@sanvi 

you can use advanced notification condition and check if record has attachment or not

how are you triggering email?

what's your business requirement?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader