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

Syed zabiullah
Tera Expert

To send a notification when the Assigned To user adds an attachment to a Case.

  • Created a Business Rule on the sys_attachment table.
    It checks if the attachment is for a Case and added by the Assigned To user.
  • If yes, it triggers a custom event.
  • Then I created a notification for that event.
  • Notification is sent only when the Assigned To user adds the attachment.



        if (cGR.assigned_to == current.sys_created_by) {
            gs.eventQueue('case.attachment.by.agent', cGR, cGR.sys_id, cGR.assigned_to);
        }

    If my response helped, please mark it correct.

Regards,
Syed K

Hi @Syed zabiullah .,

 

Sorry the email needs to be triggered only if attachment is not added by Assigned to user.

 

I have configured the below script to trigger notification once an attachment is added.

In this i have to check if attachment is added by assigned to user, if yes then notification should not be triggered.

 

var erCase = new GlideRecord('sn_hr_er_case');
    if (erCase.get(current.table_sys_id)) {
     gs.eventQueue('sn_hr_er.add_attachment', erCase, current.file_name);
 }

Muhammad Salar
Giga Sage

Hi @sanvi 
You can do this by creating a Business Rule on sys_attachment.

Advanced: checked

When to Run: After, Insert. 

Condition: Table name is "your case table"

Script:

 var caseGR = new GlideRecord('your_case_table');
    if (!caseGR.get(current.table_sys_id)) {
        return;
    }

    if (!caseGR.assigned_to) {
        return;
    }
	
    if (caseGR.assigned_to.user_name.toString() == current.sys_created_by.toString()) {
		gs.info('Condition True');
        //Fire event/notification gs.eventQueue
    }



Hi @Muhammad Salar ,

 

I have configured the below script to trigger notification once an attachment is added.

In this i have to check if attachment is added by assigned to user, if yes then notification should not be triggered.

 

var erCase = new GlideRecord('sn_hr_er_case');
    if (erCase.get(current.table_sys_id)) {
     gs.eventQueue('sn_hr_er.add_attachment', erCase, current.file_name);
 }