Copy attachment to Incident inbound action

Dawid2
Giga Guru

Hello,

I am using this code to create incident:

(function() {
   /*try {
	  var strSubject = email.subject.toLowerCase();
      if (strSubject.indexOf('re: ') == 0) {
	 return;
	 */
	  
	  var ih = new InboundUtils(email.to);
	  
	  if (!ih.canCreate()) {
		 ih.sendReplyEmail(email.from, 'Sir/Madam', email.subject);
		 return;
	  }
	  
	  current.assignment_group = ih.getInboundGroup();
	  
	  current.category = "incident";
      
      current.comments = "received from: " + email.origemail + "\n\n"
      + email.body_text;
      
      current.short_description = email.subject;
      
      var sid = gs.createUser(email.from);
      
      current.caller_id = 'sid';
      current.opened_by = 'sid';
      //current.location = ih.getLocation(sid);
      current.incident_state = 1;
      current.contact_type = "email";
      current.description = email.body_text;    
      current.insert();
   /*} catch(err) {
      var strErr = 'Error in Inbound Action : DEV Create Incident (Reply)'
      + '\n\nError Type: ' + err.name
      + '\nError message: ' + err.message;
      logIt(strErr, 'error');*/
   }
)()

Incident gets created fine, but if there is an attachment in the original email, it's not being copied over to Incident created. What part of the code am I missing? We're on Fuji.

4 REPLIES 4

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

 

Try using

GlideSysAttachment.copy("source table", source table ID, "incident", incident sys id);


Thanks,
Ashutosh

Hi Ashutosh,

So am I right in my understanding that below should work?

 

GlideSysAttachment.copy('sys_email', sys_email.sys_id, 'incident', incident.sys_id); ?

Hi,

 

Yes you can use this.


Thanks,

Ashutosh

We have a domain-separated environment and we tried this but it does not work for us.

Our inbound action is in the global domain whereas the Incident target record is in the child domain.

While trying the copied API, it does not work but the same API works from the Backgroud script.

Any suggestions on how to make it work?