I am trying to create a function that will trigger on submission of a single record form grid, search for duplicates of a certain field, and then generate a javascript confirm box that will let the user decide whether or not to submit the record.
Using the videos and support forums, I have created an AJAX callback function triggered on the Javascript System CanGridSubmit event.
var rowNum = {grid.object}._selectedRow;
{grid.Object}.ajaxCallback('G',rowNum,'Submit','','_getData=true');
The Submit function uses SQL to search for the duplicate records. But I'm having trouble with the Xbasic and Javascript below. I can't figure out how to cancel the submit. I've tried another AJAX callback, but it seems like that fires too late, after the submit has happenned.
jscmd = jscmd + <<%js%
var answer = confirm('Ok To Add Record');
if(answer == true) {
alert('Record will be added');
} else {
alert('Record will not be added');
var rowNum = {grid.object}._selectedRow;
{grid.Object}.ajaxCallback('G',rowNum,'DontSubmit','','_getData=true');
}
%js%
Submit = jscmd
--
Is there a way to send a 'return false' back to the CanGridSubmit event handler if the person cancels?
--
The second part of the question is:
I see how to create a javascript alert box using a variable Xbasic below.
dim msc as c
msg = "This is A Duplicate Record With AcctID: " + results' (Results are the list of duplicate ids)
msg = js_escape(msg)
Submit = msg
dim jscmd as c
jscmd = "alert('" + msg + "');"
But I would really like to have the msg variable used directly in the confirm box.
However, I believe the confirm box must be in the javascript section so the if statement can be based on the result of the confirm box, and I dont know how to pass that msg variable to the confirm statement.
Any help would be appreciated.
Steve Jenkins
Using the videos and support forums, I have created an AJAX callback function triggered on the Javascript System CanGridSubmit event.
var rowNum = {grid.object}._selectedRow;
{grid.Object}.ajaxCallback('G',rowNum,'Submit','','_getData=true');
The Submit function uses SQL to search for the duplicate records. But I'm having trouble with the Xbasic and Javascript below. I can't figure out how to cancel the submit. I've tried another AJAX callback, but it seems like that fires too late, after the submit has happenned.
jscmd = jscmd + <<%js%
var answer = confirm('Ok To Add Record');
if(answer == true) {
alert('Record will be added');
} else {
alert('Record will not be added');
var rowNum = {grid.object}._selectedRow;
{grid.Object}.ajaxCallback('G',rowNum,'DontSubmit','','_getData=true');
}
%js%
Submit = jscmd
--
Is there a way to send a 'return false' back to the CanGridSubmit event handler if the person cancels?
--
The second part of the question is:
I see how to create a javascript alert box using a variable Xbasic below.
dim msc as c
msg = "This is A Duplicate Record With AcctID: " + results' (Results are the list of duplicate ids)
msg = js_escape(msg)
Submit = msg
dim jscmd as c
jscmd = "alert('" + msg + "');"
But I would really like to have the msg variable used directly in the confirm box.
However, I believe the confirm box must be in the javascript section so the if statement can be based on the result of the confirm box, and I dont know how to pass that msg variable to the confirm statement.
Any help would be appreciated.
Steve Jenkins
Comment