I created a "populate controls in a dialog from a table" actionscript in the onDialogInitialize server side event. I copied and pasted the xbasic from that actionscript into my "loadRecord" function/ajax callback defined in Xbasic Functions. The session.SubdivisionID does exist but the controls are not being populated. I don't know but maybe it has to do with the rtc object? Am I trying to send the data from the table to a function named rtc back to the browser? Any help is appreciated.
Code:
session.SubdivisionID = e.dataSubmitted.Subdivision dim rtc as p rtc = e.rtc rtc.fatalError = .f. dim tmpl as p tmpl = e.tmpl if eval_valid("session.SubdivisionID") = .f. then rtc.fatalError = .t. rtc.errorText = "Variable for Primary Key values not found. Variable name: session.SubdivisionID" end if if rtc.fatalError = .f. then dim jsErrorMessage as c = "" dim primaryKeyValue as c = "" + eval("session.SubdivisionID") if primaryKeyValue <> "" then dim count as n count = w_count(primaryKeyValue,"|||") dim e.primaryKey[count] as c dim i as n for i = 1 to count e.primaryKey[i] = word(primaryKeyValue,i,"|||") next i end if end if rtc.hasError = .f. dim jsPopulateControls as c = "" dim jsErrorMessage as c = "" dim jsDebuggingMessages as c = "" if rtc.fatalError = .f. then rtc.hasError = .f. if primaryKeyValue <> "" then dim opx as p opx.flagComputeWorkDoneHTML = .f. opx.captureRawData = .f. opx.dotvarNameForRawData = "_data" opx.recordNotFoundErrorText = "Record not found" if opx.dotvarNameForRawData = "" then opx.dotvarNameForRawData = "_data" end if a5DialogHelper_populateControlsFromTable(tmpl,e,rtc,100,opx,null_value()) if rtc.fatalError = .f. .and. rtc.hasError = .f. then if opx.captureRawData = .t. then eval(opx.dotvarNameForRawData) = eval("opx." + opx.dotvarNameForRawData) end if end if else rtc.javascriptResponse = "" rtc.workDoneHTML = "" end if if rtc.hasError = .f. .and. rtc.fatalError = .f. then jsPopulateControls = rtc.javascriptResponse end if end if if rtc.fatalError = .t. .or. rtc.hasError = .t. then e.showGlobalError = .t. dim errorText as c errorText = rtc.errorText if rtc.fatalError = .t. then errorText = "Populate Dialog from Tables Action did not run because of an error." + crlf() + errorText end if errorText = stritran(errorText,crlf(),"<br>") jsErrorMessage = "var ele = $('"+tmpl.alias+".GLOBALERRORS')" +crlf()+\ "if(ele) $svs(ele,'"+js_escape(errorText)+"'); " + crlf()+\ "if(ele) ele.style.display = '';" 'Set back to .f. so that the dialog continue executing normally. The error will be reported on the Dialog screen. rtc.fatalError = .f. else jsErrorMessage = "var ele = $('"+tmpl.alias+".GLOBALERRORS')" +crlf()+\ "if(ele) $svs(ele,'"+js_escape("")+"'); " + crlf()+\ "if(ele) ele.style.display = 'none';" end if dim e.javascript as c = default "" e.javascript = e.javascript + crlf()+\ jsPopulateControls + crlf()+\ jsErrorMessage + crlf()+\ jsDebuggingMessages
Comment