Unable to attach attachment to data source table.

Vinayak Nikam
Kilo Contributor

Hi All,

Target: generate attachment through third party integration and add it into data source.

I am using below code to generate attachment through rest message and attache to data source but not getting attachment. when i am trying with incident table its working perfectly but also getResponseAttachmentSysid() returns null. 

any help appreciate.

 

//Data Source Code:

var integrationProcessGrTable="sys_data_source";
var gr1="29c4123d2f834010d0a6cc96f699b6dd";

var fileName="vuNT_.json" ;

var request = new sn_ws.RESTMessageV2('test', 'Default GET');

request.saveResponseBodyAsAttachment(integrationProcessGrTable, gr1, fileName);
response = request.execute();
httpResponseStatus = response.getStatusCode();
gs.print("Attachment sys_id :-"+response.getResponseAttachmentSysid())
gs.print(" http response status_code: " + httpResponseStatus);

-----------------------------------------------------------------------------------------------------------------------------------------------

//Incident Code

//Working but getResponseAttachmentSysid() returns null

 

var integrationProcessGrTable="incident";
var gr1="ad6f1ef12fc34010d0a6cc96f699b6b2";

var fileName="vuNT_.json" ;

var request = new sn_ws.RESTMessageV2('test', 'Default GET');

request.saveResponseBodyAsAttachment(integrationProcessGrTable, gr1, fileName); 
response = request.execute(); 
httpResponseStatus = response.getStatusCode(); 
gs.print("Attachment sys_id :-"+response.getResponseAttachmentSysid())
gs.print(" http response status_code: " + httpResponseStatus);

 

Thanks in Advance

Vinayak

6 REPLIES 6

Hi Vinayak,

as an admin from the data source record are you able to attach the file using attachment icon?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Michael Ritchie
ServiceNow Employee
ServiceNow Employee