I have a Xbasic function which looks up data from an SQL database and then passes it to a Javascript function.
Xbasic
Javascript
I get a Syntax Error when running in Working Preview. Live Preview generates no error and works. What am I missing here?
Xbasic
Code:
function getCustomerStatus as c (e as p) 'debug(1) dim cn AS SQL::Connection dim rs AS SQL::ResultSet dim args AS SQL::Arguments dim js as c dim sqlStmt as c dim flag as l dim custStatus as c dim customer_id as n 'get the Customer ID customeridtemp = e.dataSubmitted.customeridtemp flag = cn.Open("::Name::SQL") if flag = .f. then cn.close() js = "alert('Error Connecting to Database);" getCustomerStatus = js exit function end if 'lookup from the database and get the customer info sqlStmt = "SELECT * FROM Customers WHERE customer_id = :custid" args.set("custid", customeridtemp) flag = cn.Execute(sqlStmt,args) if flag = .f. then cn.close() js = "alert('Error executing query');" getCustomerStatus = js exit function end if rs = cn.ResultSet custStatus = rs.ToJSONObjectSyntax() 'pass back a call to a Javascript function... including the customer info data... now in JSON format. getCustomerStatus = "processCustomerStatus('" + custStatus + "');" cn.close() end function
Code:
function processCustomerStatus(custStatus) { var custObj = JSON.parse(custStatus); var customer_id = custObj.customer_id; var firstname = custObj.FirstName; var lastname = custObj.LastName; var city = custObj.City; var state = custObj.State; var zip = custObj.Zip; var phone = custObj.PhoneNumber; var email = custObj.Email; {dialog.object}.setValue('FirstName',firstname); {dialog.object}.setValue('LastName',lastname); {dialog.object}.setValue('City',city); {dialog.object}.setValue('State',state); {dialog.object}.setValue('ZipCode',zip); {dialog.object}.setValue('PhoneNumber',phone); {dialog.object}.setValue('Email',email); {dialog.object}.setValue('firstname_vb',firstname); {dialog.object}.setValue('lastname_vb',lastname); {dialog.object}.setValue('city_vb',city); {dialog.object}.setValue('state_vb',state); {dialog.object}.setValue('zipcode_vb',zip); {dialog.object}.setValue('phoneNumber_vb',phone); {dialog.object}.setValue('phoneNumber_vb_temp',phone); {dialog.object}.setValue('email_vb',email); {dialog.object}.panelSetActive('REVIEW_PANEL'); }
Comment