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.

How to load Attachments to table using REST API for the custom file attachment fields.

ah16
Mega Expert

Hi,

I have custom multiple fields of type file attachment. How can I load attachments thru REST API to the custom file attachment fields?

 

Where to find how this table name created for this custom fields  "zz_yydmn_demand" ?find_real_file.png Thanks,

Ashraf

1 ACCEPTED SOLUTION

Hi,

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

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

7 REPLIES 7

sachin_namjoshi
Kilo Patron
Kilo Patron

Use below to create attachments via REST API

 

https://community.servicenow.com/community?id=community_article&sys_id=e0dc2665dbd0dbc01dcaf3231f961...

 

Regards,

Sachin

Kunal Varkhede
Tera Guru

Hi,

 

Using Attachment API it is possible to load attachment

Go through this below doc

https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/c_AttachmentAPI

 

Thanks,

Kunal

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ashraf,

So are you saying you are having a field of type "File Attachment"

but you are unable to add file to that

Regards
Ankur

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

Thanks Ankur for your response. Since, I have two custom file attachment fields, how do I know which file is being attached to which one thru script? As, I don't see name of the fields.

For custom fields, it has table name  "zz_yydmn_demand". I didn't find this table info when I looked at custom field dictionary. Where can I find this table name?

 

 

find_real_file.png