How to copy attachment from one record to another record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 03:07 AM
Hi Everyone,
I have a requirement, the scenario is that upon insert the attachment in the Customer Service application that I have created will automatically copied to the incident record.
the case is that if an agent is about to submit a ticket from the customer service application, once he indentified that this is an incident it will automatically create an incident ticket, I was successful on that part but the problem is that the attachment is not included once the incident record is created. I have this code but it is not working, hope someone can help me.
Business Rule
Table: Customer Service
When to Run: After / Insert
Script:
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('x_glti_incident_ma_incident_management_table');
ritm.addQuery('x_glti_customer_se_customer_service_ticket',current.sys_id);
ritm.query();
while(ritm.next()){
GlideSysAttachment.copy('x_glti_customer_se_customer_service', current.sys_id, 'x_glti_incident_ma_incident_management_table', ritm.sys_id);
}
})(current, previous);
Many thanks in advance
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 03:34 AM
I believe the problem here is that there are two business rule, one for inserting incident record after the call is submitted and another is for copying attachment.
You have to change the order and I guess the issue is that, it might execute at the same time,so may be the sys_id won't be available in the the system.
Try by checking log as gs.log(ritm.sys_id); so it would be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 03:44 AM
Hi Vinoth,
I think that is not the problem because I have another BU runs at the same just to copy the ticket number of incident after insert and the query I used is the reference number form the customer service application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 04:49 AM
I Hope Someone can hep me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 05:01 AM
I am not sure why it is not working, maybe this 2 application is a scope application since i just made it from scratch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 05:05 AM
I suspect the scope also. Rest is quite straight forward.