Chavan AP
Kilo Sage

Create a widget as shown below to submit an incident:

find_real_file.png

 

Follow below Steps:

1. Navigate to Service Portal => Service Portal Configuration

find_real_file.png

2. Click on Widget Editor 

find_real_file.png

3. Click on Create New Widget

find_real_file.png

4. Fill Widget Name and Submit

find_real_file.png

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.

find_real_file.png

References : docs.service-now.com, www.udemy.com , https://getbootstrap.com/docs/3.3/components/

Please mark helpful if this article helps !!

Regards,

Ajay

 

 

 

 

 

 

Comments
Bhuvaneswari T1
Tera Contributor

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

 

Version history
Last update:
‎02-20-2020 02:40 AM
Updated by: