How to copy attachments using Cart API method

madhavib
Giga Contributor

HI,

I have a requirement to create a request using cart API. Now i able to create a request successfully but the problem is with attachments which i uploaded in SP are not getting copied on the request ticket.

Please give us the syntax.

4 REPLIES 4

Omkar Mone
Mega Sage

Hi 

You can use GlideSysAttachment.copy().

 

GlideSysAttachment()

copy(String sourceTable, String sourceID, String targetTable, String targetID)

Copies attachments from the source record to the target record.

 

Regards,

Omkar Mone

Hi,

below is the code which I am using in Request Record producer.

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e2132865c0a8016500108d9cee411699');
var rc = cart.placeOrder(); 


Now please let me know how to pass parameters in Glidesysatatchment copy syntax?

 

Hi

Try with this once

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e2132865c0a8016500108d9cee411699');
var rc = cart.placeOrder(); 

var attch = new GlideSysAttachment();
attach.copy("your_table_name", rc.sys_id, "target_table", rc.sys_id)

var attch = new GlideSysAttachment();
attach.copy('rc', 'rc.sys_id', 'sc_request', 'current.sys_id');

 

This is the syntax I am using. Attachments are getting copied But now the request is creating with NO ritm's