Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Attachment API to attach file in attachment field instead of record

guestee
Tera Contributor

HI All,

I have a requirement to attach a file into custom field (type : file attachment) in a record via API. Is it possible. 

Please suggest and help on this topic.

Sample

guestee_0-1710229428689.png

 

Thanks,

Venkat

2 REPLIES 2

Simran Gadodiya
Mega Sage

Hi @guestee 

 

what I was able to achieve is below:

1) Use Attachment API to create file -> it would create an attachment record in sys_attachment table

POST: Upload an attachment from a binary request

Gave table name as ZZ_YYtable_name; in your case it would be ZZ_YYdmn_demand

Gave the table_sys_id -> record sys_id

file name -> you want

Request body -> attachment data

2) now you will have to populate the attachment sys_id from step 1 in the field which is of type File Attachment on that record; once you update that field with that sys_id it should start showing

Reference :

https://www.servicenow.com/community/developer-forum/how-to-load-attachments-to-table-using-rest-api...

https://docs.servicenow.com/bundle/vancouver-api-reference/page/integrate/inbound-rest/concept/c_Att...

 

Mark it as  Helpful and correct  if you find my response worthy based on the impact.
Thanks

Thanks Simran for your detailed help.

One query if we do the Point 1 , attachment will be added to the record as well (added to the record frame header) ,we dont want to show the attachment on the record header frame. Any suggestion?