- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 05:45 AM
Hi,
I have two questions please.
1. The code isn't working.
function demoClientScript() {
var answer = confirm('Do you want to close Child incident?');
if (answer == true) {
gsftSubmit(null, g_form.formElement(), 'sys_demoaction');
}
}
var gr = new GlideRecord('incident');
gr.addQuery('parent_incident', current.sys_id);
gr.query();
while(gr.next()){
gr.state = '7';
gr.resolution_code='duplicate';
gr.resolution_notes='I love you Cloeh';
gr.update();
}
action.setRedirectURL(current);
2. In very simple terms please explain me when should I use 'current' and when should I use 'gr.
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 05:49 AM - edited 02-27-2025 05:51 AM
current means the glideRecord object of the form being opened
gr is just name of gliderecord object for your table mentioned i.e. incident
update script as this
function demoClientScript() {
var answer = confirm('Do you want to close Child incident?');
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'sys_demoaction');
}
}
if (typeof window == 'undefined')
runServerCode();
function runServerCode() {
var gr = new GlideRecord('incident');
gr.addQuery('parent_incident', current.sys_id);
gr.query();
while (gr.next()) {
gr.state = '7';
gr.resolution_code = 'duplicate';
gr.resolution_notes = 'I love you Cloeh';
gr.update();
}
action.setRedirectURL(current);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 05:49 AM - edited 02-27-2025 05:51 AM
current means the glideRecord object of the form being opened
gr is just name of gliderecord object for your table mentioned i.e. incident
update script as this
function demoClientScript() {
var answer = confirm('Do you want to close Child incident?');
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'sys_demoaction');
}
}
if (typeof window == 'undefined')
runServerCode();
function runServerCode() {
var gr = new GlideRecord('incident');
gr.addQuery('parent_incident', current.sys_id);
gr.query();
while (gr.next()) {
gr.state = '7';
gr.resolution_code = 'duplicate';
gr.resolution_notes = 'I love you Cloeh';
gr.update();
}
action.setRedirectURL(current);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 06:02 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader