Attachment variable on record producer not getting added as attachment on case

Mike Strik
Tera Guru

When using the variable "Attachment" the attachment is not included in the form.

In history I see its included: find_real_file.png

But on the form (backend) I dont see an attachment:

find_real_file.png

On the front (ticket form), I see the attachment in the conversation:

find_real_file.png

But on the same screen the attachment is empty:

find_real_file.png

 

Anyone can help me out?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Sorry, I adapted this from another table and had a typo.  In any event, testing this specific scenario I have found that it seems to work better, which means actually work in this case, if the Business Rule is async instead of after.  You'll also want to create the BR in the Global scope since you're updating a global table.

find_real_file.png

Here's the working script, using a better way to specify the table name, which will make it easier to apply the same to other tables. 

(function executeRule(current, previous /*null when async*/) {
	var attach = new GlideRecord('sys_attachment');
	attach.addQuery('table_name', 'ZZ_YY' + current.getTableName());
	attach.addQuery('table_sys_id', current.sys_id);
	attach.query();
	if(attach.next()){
		attach.table_name = current.getTableName();
		attach.update();
	}	
})(current, previous);

View solution in original post

8 REPLIES 8

Hi Brad,

 

Thanks again for your reply. I did everything like you told me to configurate.

I'm very new in the scripting part. Do I need to change parameters in the script to get it working? Now I just copied/pasted it in the BR.

 

Thanks!

Inactivate the first BR you created, then create a new one in the Global application the same way you created the first one, except with the updated script I provided.

Yes! Its working now. I don't know what went wrong. This morning I deleted the old BR, made the new one and it was not working. Now I tried it again, and its working!

Thanks!

 

Mike Strik
Tera Guru

Hi Brad,

 

Thanks for your fast reply. I just verified and the table is named ZZ_YYsn_customer_service_case.

 

 

I'm trying to setup a proper Business Rule. I'm clearly doing something wrong, because it doesn't work the way that I configured it.

 

When to run:

Actions:

 

Advanced:

If I like look under tables, I don't see a table named: sc_customerservice_case. I tried renaming it in the script to sn_customerservice_case. This doesn't matter.

Can you help me configure this rule?

 

Thanks again!