- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2017 10:17 PM
I Wants to print current record number inserted in table after click Submit button
I am new to Swericenow please help
here is code
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
Hello Welcome to New Test Page
<table>
<tr>
<td> Name </td>
<td> <input type="text" id="fname" name="fname"/> </td>
</tr>
</table>
<input type="submit" value="Save Record" onclick="return ins();"/>
<script>
function ins()
{
var gr = new GlideRecord('x_94496_econtact_a_network_voice');
gr.initialize();
gr.csc_short_name = document.getElementById("fname").value;
gr.insert();
alert ("Record inserted");
gs.print('Incident Number is ' + number '); // Number is column name where auto number value would be generated once record inserted into table.
}
</script>
</j:jelly>
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 05:42 AM
Use the below code.
var gr = new GlideRecord('x_94496_econtact_a_network_voice');
gr.initialize();
gr.csc_short_name = document.getElementById("fname").value;
var id= gr.insert();
var gr1= new GlideRecord('x_94496_econtact_a_network_voice');
gr1.get(id);
alert ("Record inserted" + gr1.number);
Thanks,
Jagarnath

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2017 10:23 PM
Hello Mahather,
Function print is not allowed in scope app. Use gs.debug() or gs.info() instead
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2020 09:47 AM
But why? This seems like such a simple function. 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2017 11:55 PM
No it doesn't work .. please help me with sample code.. or please correct above code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 12:20 AM
Hello Mahather,
Why are you using gs.print in the script?
Do you want to log something in the system log?
As Pradeep said - gs.print does not work in scopes different than the Global one.
If you try to execute your script and only the gs.print is the problem, then you will receive a warning notification from the SNOW, informing you that gs.print does not work in custom application's scope. So you will need to use gs.info or gs.debug.
If you may skip your request of logging info in the system log, then you may simply remove gs.info from your script and try it that way.
Best Regards,
Georgi Mavrodiev
IT Consultant
Do IT Wise
You may visit us in our Web Site: www.doitwise.com