GlideSysAttachment.copy() used in Record producer does'nt seem to work in service portal

Nishanth Nagesh
Giga Contributor

Hi Everyone,

I have a record producer based on task table. Have some conditions to create an inc/req accordingly.

GlideSysAttachment.copy() is used to copy the attachments from task record to incident/req. This functionality is working fine when I create a record using "Try it" UI action. But when I try to do the same thing from Service Portal it doesn't work. I can see an entry in Sys_attachment table though.

Please share your inputs.

Thanks

Nishanth

12 REPLIES 12

anvesh_v
Giga Guru

Hi Nishnth ,



  Are you using the same paper clip icon in the service portal or you have created a new macro   for attaching   files in the portal .




Thanks & Regards


Anvesh


Hi Anvesh,



Yes, I am using the same paper clip icon.



Thanks


Nishanth


Hi Nishanth ,



Is this a service created   record producer then find this link ServiceNow KB: PRB622511: Service Creator record producers do not pass the attachment through to the...  



Thanks & Regards


Anvesh


Hi Avnesh,



No it is not. Below is my record producer code.



current.setAbortAction(true); //abort current producer action - Task record creation
processSubmission();



//function to create a new incident or a request
function processSubmission()
{
//Common fields which will be copied.
var gr = new GlideRecord(producer.lc_sys_class_name);
gr.initialize();
gr.u_requestor = producer.lc_requested_for;
gr.cmdb_ci = producer.lc_affected_ci;
gr.priority = producer.lc_priority;
gr.description = producer.lc_description + '\n' + 'New HostName: ' +producer.lc_new_hostname;
gr.short_description = producer.lc_description;
gr.contact_type = 'self-service';
gr.u_record_producer = current.sys_id;
//var user = gs.getUserName();
//var cid = current.sys_id;



if(producer.lc_sys_class_name == 'incident')  
  {
            gr.category = producer.lc_inc_category;
            gr.subcategory = producer.lc_inc_subcategory;
            gr.insert();        
            GlideSysAttachment.copy('task', current.sys_id,'incident', gr.sys_id);// works fine in traditional way, not in service portal.
 
  I tried querying Sys_attachment table here. The execution does not enter the if part when I use table_name and tabl_sys_id in addQuery.
  /*
 
              var attachments = new GlideRecord('sys_attachment');
          attachments.addQuery('table_name', 'task');
          attachments.addQuery('table_sys_id', current.sys_id);
          attachments.query();
          gs.log('I am here....');
          if (attachments.next())


{
                      gs.log('I am here');
                      attachments.table_name = 'incident';
                      attachments.table_sys_id = gr.sys_id;
                      attachments.update();
}*/



}



if(producer.lc_sys_class_name == 'sc_request')
  {
    gr.category = producer.lc_req_category;
    gr.subcategory = producer.lc_req_subcategory;
    gr.insert();
    GlideSysAttachment.copy('task', current.sys_id, 'sc_request', gr.sys_id);
             
   
  }
}