- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 02-20-2020 02:40 AM
Create a widget as shown below to submit an incident:
Follow below Steps:
1. Navigate to Service Portal => Service Portal Configuration
2. Click on Widget Editor
3. Click on Create New Widget
4. Fill Widget Name and Submit
5. Now Use Below HTML Script:
<div class ="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Create an Incident
</h4>
</div>
<div class="panel-body">
<form>
<div class="form-group">
<lable for=issue>Issue</lable>
<input type="text" class="form-control"
id="issue"
placeholder="Please enter issue"
ng-model="data.newIncident.issue"/>
</div>
<div class="form-group">
<lable for="urgency" >Urgency</lable>
<select id="urgency"
class="form-control"
ng-model="data.newIncident.urgency">
<option value="1">High</option>
<option value="2">Medium</option>
<option value="3">Low</option>
</select>
</div>
</form>
</div>
<div class="panel-footer">
<button class="btn btn-success" ng-click="c.submit()"> Submit
</button>
</div>
</div>
6. Use below Client Script:
function() {
/* widget controller */
var c = this;
c.submit =function(){
c.data.action='createIncident';
c.server.update();
}
}
7. Use Below Server Script
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.newIncident={
issue:'',
urgency:''
}
if(input && input.action ==="createIncident")
{
createIncident(input.newIncident);
}
function createIncident(inc)
{
var gr=new GlideRecord('incident');
gr.newRecord();
gr.setValue('caller_id',gs.getUserID());
gr.setValue('short_description',inc.issue);
gr.setValue('urgency',inc.urgency);
gr.insert();
}
})();
Now if you access preview this widget it will look as below and will give you an ability to Submit a new incident.
References : docs.service-now.com, www.udemy.com , https://getbootstrap.com/docs/3.3/components/
Please mark helpful if this article helps !!
Regards,
Ajay
- 7,330 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi AjayChavan,
In server Script in function createIncident you passed inc as an argument. Where is that defined? I didn't get it could you explain it.
Thank you,
Bhuvaneswari T