- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 11:06 AM
function onSubmit() {
//Type appropriate comment here, and begin script below
var a = g_form.getValue('group_name');
var ga = new GlideAjax('isGroupCreated');
ga.addParam('sysparm_name', 'isNameExists');
ga.addParam('Group_Name', a);
ga.getXMLWait();
var answer = ga.getAnswer();
var mem = g_form.getValue('EU06') ? g_form.getValue('EU06').split(',').length : 0;
if (answer == 'false') {
alert('Group wih the same name already exists:\nPlease try with Different Name');
return false;
} else if (answer == 'true') {
alert('Name is Unique');
var anna = confirm('Please Confirm Your Request Details: \nGroup Name: '+g_form.getValue('group_name')+'\nDescription: '+ g_form.getValue('EU02')+'\nGroup Email: '+g_form.getValue('EU03')+'\nManager for the group: '+ g_form.getDisplayBox('EU04').value+'\nNumber of Members: '+ mem);
if (anna == false){
return false;}
}
}
Hi Community,
This above code is working fine , when I use 'Try It' in Catalog Item and try to submit the item, but doesnt work the same when I happen to use this in my EmployeeCenter [ESC] it says 'Javascript Error'.
Also Above the Catalog Client Script this info pops up:
This catalog client script is not VA supported due to the presence of the following variables in the script: g_form.getDisplayBox.value, confirm New client-scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype and the window object are likewise disabled. To disable this on a per-script basis, configure this form and add the "Isolate script" field. To disable this feature for all new globally-scoped client-side scripts set the system property "glide.script.block.client.globals" to false. |
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 11:35 AM
You have to put it in a function for portal. Try this:
function onSubmit() {
if (g_scratchpad.isFormValid) //need to check to see if you should process or not
return true;
var a = g_form.getValue('group_name');
var ga = new GlideAjax('isGroupCreated');
ga.addParam('sysparm_name', 'isNameExists');
ga.addParam('Group_Name', a);
ga.getXMLAnswer(getResponse);
return false;
}
function getResponse(response) {
var answer = response;
var mem = g_form.getValue('EU06') ? g_form.getValue('EU06').split(',').length : 0;
if (answer == 'false') {
alert('Group wih the same name already exists:\nPlease try with Different Name');
return false;
} else if (answer == 'true') {
alert('Name is Unique');
var anna = confirm('Please Confirm Your Request Details: \nGroup Name: ' + g_form.getValue('group_name') + '\nDescription: ' + g_form.getValue('EU02') + '\nGroup Email: ' + g_form.getValue('EU03') + '\nManager for the group: ' + g_form.getDisplayBox('EU04').value + '\nNumber of Members: ' + mem);
if (anna == false) {
return false;
}
}
var actionName = g_form.getActionName();
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 11:35 AM
You have to put it in a function for portal. Try this:
function onSubmit() {
if (g_scratchpad.isFormValid) //need to check to see if you should process or not
return true;
var a = g_form.getValue('group_name');
var ga = new GlideAjax('isGroupCreated');
ga.addParam('sysparm_name', 'isNameExists');
ga.addParam('Group_Name', a);
ga.getXMLAnswer(getResponse);
return false;
}
function getResponse(response) {
var answer = response;
var mem = g_form.getValue('EU06') ? g_form.getValue('EU06').split(',').length : 0;
if (answer == 'false') {
alert('Group wih the same name already exists:\nPlease try with Different Name');
return false;
} else if (answer == 'true') {
alert('Name is Unique');
var anna = confirm('Please Confirm Your Request Details: \nGroup Name: ' + g_form.getValue('group_name') + '\nDescription: ' + g_form.getValue('EU02') + '\nGroup Email: ' + g_form.getValue('EU03') + '\nManager for the group: ' + g_form.getDisplayBox('EU04').value + '\nNumber of Members: ' + mem);
if (anna == false) {
return false;
}
}
var actionName = g_form.getActionName();
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 11:40 AM
Hey Jennifer, thats right the thing I was looking out for. TYSM!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 11:49 AM
Hi
var anna = confirm('Please Confirm Your Request Details: \nGroup Name: ' + g_form.getValue('group_name') + '\nDescription: ' + g_form.getValue('EU02') + '\nGroup Email: ' + g_form.getValue('EU03') + '\nManager for the group: ' + g_form.getDisplayBox('EU04').value + '\nNumber of Members: ' + mem);
Hi in your Solution, the above part is not working in the sense, that its not showing any confirm and asking for ok or cancel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 04:59 AM
I pulled that statement directly out of your initial code. Is the alert statements above it popping up? So you are sure you are making it to that statement? If so, you may try adding .toString() after each of your getValue statements. Sometimes it's picky like that.