How to store attachment in sys_attachment table
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 03:38 AM
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 03:48 AM
Hi,
which form/page is that?
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 04:36 AM
Hi, here is an example widget:
HTML
<div>
<input name="myFile" type="file" />
<button ng-click="c.upload();" />
</div>
Client controller:
api.controller=function(snAttachmentHandler, spUtil) {
var c = this;
var table = 'problem';
var sysId = '1998e51967b032004792adab9485effa';
var handler = snAttachmentHandler.create(table, sysId, {
onUploadComplete: function () {
spUtil.addInfoMessage('upload success');
}
});
c.upload = function () {
var input = document.querySelector('#x' + c.widget.rectangle_id + ' input[name="myFile"]');
if (input && input.files.length) {
handler.uploadAttachment(input.files[0]);
}
};
};
Please let us know if this solved your problem.