In my data bound UX (SQL backend) the below xbasic function is called via a button that first executes some JS and then goes on to this function. The function works as expected EXCEPT my e.javascript parts seems to be ignored. You can see i have a couple alerts setup but the never appear. I use e.javascript in my server-side xbasic functions and they work fine. But here in the 'xbasic functions' they are not. I don't get it...
When a button is pressed this JS runs first...
...if the user entered data the JS above then calls upon my xbasic function...
The code in RED is what seems to be ignored .... am i doing something wrong??
When a button is pressed this JS runs first...
Code:
var mrnum = prompt("Please enter a new MR number and press OK.", ""); if (mrnum == null) { alert("You pressed cancel or didn't enter a MR number."); } else if (mrnum != null){ {dialog.Object}.setValue('JS_Variable',mrnum); {grid.Object}.ajaxCallback('G','{Grid.RowNumber}:all','Duplicate_Patient','','',{deviceOfflineFunction: function() { }}); } else { }
Code:
function Duplicate_Patient as c (e as p) 'Check to make sure MR num entered by user is unique 'Duplicate patient data in SQL and add an entry into the PatientStatus table dim cn as sql::connection dim args as sql::arguments dim rs as sql::ResultSet dim result as l args.set("arg1","Active") args.set("arg2",e._currentRowDataNew.ClientID) args.set("arg3",e._currentRowDataNew.FirstName) args.set("arg4",e._currentRowDataNew.Initial) args.set("arg5",e._currentRowDataNew.LastName) args.set("arg6",e._currentRowDataNew.Sex) args.set("arg7",e._currentRowDataNew.Date_of_birth) args.set("arg8",e._currentRowDataNew.SSN) args.set("arg9",e._currentRowDataNew.Race) args.set("arg10",e._currentRowDataNew.Religion) args.set("arg11",e._currentRowDataNew.Language) args.set("arg12",e._currentRowDataNew.Marital_status) args.set("arg13",e._currentRowDataNew.Ethnicity) args.set("arg14",e._currentRowDataNew.Phone) args.set("arg15",e._currentRowDataNew.Fax) args.set("arg16",e._currentRowDataNew.Cell) args.set("arg17",e._currentRowDataNew.OtherPhone) args.set("arg18",e._currentRowDataNew.Address) args.set("arg19",e._currentRowDataNew.GateCode) args.set("arg20",e._currentRowDataNew.Mileage) args.set("arg21",e._currentRowDataNew.City) args.set("arg22",e._currentRowDataNew.State) args.set("arg23",e._currentRowDataNew.Zip) args.set("arg24",e._currentRowDataNew.County) args.set("arg25",e._currentRowDataNew.Height) args.set("arg26",e._currentRowDataNew.JS_Variable) args.set("arg27",0) 'args.set("arg28",val(e._currentRowDataNew.RC)) 'args.set("arg29",val(e._currentRowDataNew.CC)) 'args.set("arg30",val(e._currentRowDataNew.RSPT)) 'args.set("arg31",val(e._currentRowDataNew.GIP)) result = cn.Open("::Name::sql") if result sqlSelect = "SELECT ID FROM Patient WHERE MRNum = :arg26 AND clientid = :arg2" result = cn.Execute(sqlSelect,args) if result rs = cn.ResultSet result = rs.nextRow() if result [COLOR="#FF0000"]e.javascript = "alert('The MR number you entered is already in use.');"[/COLOR] exit function end if end if else e.javascript = "alert('Could not connect to database.');" exit function end if cn.Execute("INSERT INTO Patient (Status, Clientid, Firstname, Initial, Lastname, Sex, DOB, SSN, Race, Religion, Language, MaritalStatus, Ethnicity, Phone, Fax, Cell, Otherphone, Address, Gatecode, Mileage, City, State, Zip, County, Height, MRNum, Record_delete) VALUES (:arg1, :arg2, :arg3, :arg4, :arg5, :arg6, :arg7, :arg8, :arg9, :arg10, :arg11, :arg12, :arg13, :arg14, :arg15, :arg16, :arg17, :arg18, :arg19, :arg20, :arg21, :arg22, :arg23, :arg24, :arg25, :arg26, :arg27)",args) cn.Execute("INSERT INTO PatientStatus (MRNum2, Status, Clientid2) VALUES (:arg26, :arg1, :arg2)",args) cn.close() [COLOR="#FF0000"]e.javascript = "alert('Patient record duplicated.');"[/COLOR] [COLOR="#FF0000"]e.javascript = "{dialog.object}.refreshListData('LIST1');"[/COLOR] end function
Comment