- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2017 05:21 AM
Hello Guys ?
I am working on a requirement, where I need to create a custom table in which we have a currency field.
It is some what like a auction amount kind where the new entry in the currency field should always be $25(minimum) more than the maximum value of that the current field in the table ?
so do we have any predefined method or I need to go with script ?
Thanks Guys....
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2017 06:49 AM
Hi Naresh,
You can try below
var count = new GlideAggregate('yourTableName');
count.addAggregate('MAX', 'yourFieldName');
count.query();
if (count.next()) {
var max = count.getAggregate('MAX', 'yourFieldName');
gs.log("Maximum value for field yourFieldName is " + max);
}
http://wiki.servicenow.com/index.php?title=GlideAggregate#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2017 06:49 AM
Hi Naresh,
You can try below
var count = new GlideAggregate('yourTableName');
count.addAggregate('MAX', 'yourFieldName');
count.query();
if (count.next()) {
var max = count.getAggregate('MAX', 'yourFieldName');
gs.log("Maximum value for field yourFieldName is " + max);
}
http://wiki.servicenow.com/index.php?title=GlideAggregate#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2017 07:22 AM
Hi Deepak ,
yup will implement on Monday and will come back to you, if any issues. Thanks for the response. By the what is the best resource to master Scripting (Client Side and Server Side )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2017 07:41 AM
one more thing, i am unable to understand the o/p of this small if condition code ! can you help me out .....
for the above code, the o/p
After changing the value to 50 which is the actual value of temp the following is the o/p
information: u_field_3 is of type integer in the table
can you comment on this .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2017 09:12 AM
for your understanding, It should be like.
var gr = new GlideRecord('u_table_1);
gr.query();
while(gr.next())
{
if(parseInt(gr.getValue('u_field_3')) > 50)
gs.print('Hello');
else
gd.print('Boxer');
}