copy attachemnet in scoped application

deepak50
Tera Contributor

Hi,

I am working on a scoped application and need to copy attachments from case record to incident record.

I tried GlideSysAttachment.copy() and GlideSysAttachment.writeContentStream() methods in script include but these are not working.

Both of these methods are working If I write the same code in background script.

Is there a way to copy attachments from one record to other in scoped application.

 

Thanks

Deepak

6 REPLIES 6

asifnoor
Kilo Patron

Hi,

When you say its not working in scoped application, are you getting any error? Because GlideSysAttachment.copy() works in scoped application as well.

Check the error logs and tell me if you see any issue.

Mark the comment as a correct answer and helpful if it helps.

deepak50
Tera Contributor

Hi,

I am not getting any error in logs. Please see code below , I am using this in script include function.

I can see both gs.info message in logs this means function executed but no error message and also attachments are not copied. Does it need some role required?? or this is not correct way to use function.

try{

 gs.info("copy attachment script include function 1:=" + caseSysId + "--" + incidentSysId);
        try {
            
          var gr=new GlideSysAttachment();
          gr.copy('sn_customerservice_case', caseSysId, 'incident', incidentSysId;
            
            
 gs.info("copy attachment script include function2:=" + caseSysId + "--" + incidentSysId);
            
            
        } catch (ex) {
            gs.error("error in copy attachment=" + ex);
        }

Hi

I assume the 2 sysids are correct and the attachments exists on the sys_id present in caseSysId.

Can you hardcode the sys_ids in the function once and check.

var attachment = new GlideSysAttachment();

attachment.copy('sn_customerservice_case', 'put case sys id here', 'incident', 'put incident sysid here');

 

 

Were you able to find the solution?

I see you are missing closing bracket in gr.copy statement (assuming it may be just typo here).