The CreatorCon Call for Content is officially open! Get started here.

I Want to create a upload files button in service portal which will attach a files to the Record

Abhi2023
Tera Contributor

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

0 REPLIES 0