Demonstration Of UI Pages | Making Incident Form in UI Page
Import
·
May 18, 2022
·
article
Hello ServiceNow Ninjas,
Today we are demonstrating the creation of an Incident form using a UI page.
This involves the use of all three components of UI page - HTML body, Client Script & processing script.
The demonstration is very well explained in the video - Click Here
Mark Helpful, If helpful.
Script Sample :-
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form id="f_id">
<center><h2> Incident Request Form </h2>
<table>
<tr>
<td>Requester : </td>
<td><g:ui_reference name="User_id" table="sys_user" field="name" id="Name" displayvalue="${gs.getUser().getDisplayName()}" value="${gs.getUser()}"/> </td>
</tr>
<tr></tr>
<tr>
<td>Category : </td>
<td> <select name="cat_id" id="c_id">
<option value="0">None</option>
<option value="inquiry">inquiry</option>
<option value="software">software</option>
<option value="hardware">hardware</option>
<option value="network">network</option>
<option value="database">database</option>
</select>
</td>
</tr>
<tr><td>Short Description : </td><td><input type="text" name="sd_id"/></td></tr>
<tr><td>Description : </td><td><textarea name="des_id" rows="4" cols="50"></textarea></td></tr>
<tr><td><input type="submit" onClick="redirect()"/></td><td><input type="reset" name="reset" onClick="onReset()"/></td></tr>
</table>
</center>
</g:ui_form>
</j:jelly>
Client Script
function onReset() {
document.getElementById("f_id").reset(); // clear the form
}
Processing Script
var inc = new GlideRecord('incident');
inc.initialize();
inc.caller_id = User_id;
inc.short_description = sd_id;
inc.description = des_id;
inc.category = cat_id;
var sys_id = inc.insert();
var URL = "https://dev125702.service-now.com/incident.do?sys_id=" + sys_id; // URL of newly created incident record
response.sendRedirect(URL); //sendRedirect() method redirects the response to another resource, inside or outside the server.
View original source
https://www.servicenow.com/community/developer-articles/demonstration-of-ui-pages-making-incident-form-in-ui-page/ta-p/2302761