I Want to create a upload files button in service portal which will attach a files to the Record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 05:38 AM - edited 04-29-2024 05:40 AM
I have created a widget in which there are two buttons one is for updating comments in the records which is fine
next is the select file button -i should be able to select multiple files and attach those files to the record same as i am updating the comments i am sharing the html,client and server code..
HTML
<div>
<label>update comments</label>
<textarea class="form-control"ng-model="data.value"></textarea>
<br>
<button class="btn btn-primary btn-sm m-l-xs"ng-click="c.update(data.value)">
update
</button>
<div class="row"><label>Select File:<input type="file"name="myFile"><br><br></label>
</div>
<!-- your widget template -->
</div>
client script
api.controller=function($window) {
/* widget controller */
var c = this;
c.update=function(value)
{
c.data.shrt = value;
c.data.check='yes';
c.data.state='6';
c.server.update();
$window.location.reload();
}
}
server script
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if(input)
{
data.sysId=input.sysids;
if(input.check == 'yes')
{
var inc= new GlideRecord('incident');
inc.addQuery('sys_id','IN',input.sysId);
inc.query();
while(inc.next())
{
inc.state=input.state;
inc.work_notes=input.shrt;
inc.update();
}
}
}
})();
## sys ids are geeting passed from another widget ,from where this widget has been called
for your reference you can just test with only one record
help me in writing the client and server side for attaching the file