This should be relatively simple (the easy things really trip me up!)
I have a grid (I'm running version 11) and I added logic to the OnSqlSelectQuery server side event. If the alpha generated SQL select returns no records, I want to pull data from another table to populate the grid. I have that all working fine (logic is below) and can confirm the data gets added to the table correctly by viewing the information in SQL Server. However, I need to have the grid do a REFRESH after the OnSqlSelectQuery runs so the new records that were entered are visible to the user. I cannot figure out how to do this! PLEASE HELP!
Here is my logic to insert the new recs. I just need the syntax to refresh the grid. Thanks in advance for your advice!
if e.recordcount = 0 .and. eval_valid("session.SESS_SEQ") then
dim fai_id as N
dim part_number as C
dim seq_number as C
dim sql as C
dim args as SQL::Arguments
' fyi, links passed from qtfai contain:
' e.rtc.links[1].fieldname = "FAI_ID"
' e.rtc.links[2].fieldname = "PART_NUMBER"
' e.rtc.links[1].value = contains value of fai_id
' e.rtc.links[2].value = contains value of part_number
if e.cn.BeginTransaction() then
fai_id = e.rtc.links[1].value
part_number = e.rtc.links[2].value
seq_number = session.SESS_SEQ
'e.handled = .t. 'override the auto generated sql with the following 'GET FATAL ERROR WHEN ADD THIS LINE
sql = "INSERT INTO QTFAINSPECT (fai_id, part_number, sequence_number, item_description, nominal, upper_limit, lower_limit, um) SELECT :fai_id, part_number, sequence_number, dim_description, nominal, upper_limit, lower_limit, um FROM partdim WHERE part_number = :part_number AND sequence_number = :seq_number" ;
args.set("fai_id", fai_id)
args.set("part_number", part_number)
args.set("seq_number", seq_number)
if e.rtc.cn.execute(sql,args) == .f. then
e.flagerror = .t.
e.errorText = "Unable to update record at this time. [CONNEXEC4] "+ e.rtc.cn.CallResult.NativeText+" | "+ e.rtc.cn.CallResult.Text
e.rtc.cn.RollBackTransaction()
else
e.rtc.cn.CommitTransaction()
end if
end if
end if
session.RemoveAll()
end function
I have a grid (I'm running version 11) and I added logic to the OnSqlSelectQuery server side event. If the alpha generated SQL select returns no records, I want to pull data from another table to populate the grid. I have that all working fine (logic is below) and can confirm the data gets added to the table correctly by viewing the information in SQL Server. However, I need to have the grid do a REFRESH after the OnSqlSelectQuery runs so the new records that were entered are visible to the user. I cannot figure out how to do this! PLEASE HELP!
Here is my logic to insert the new recs. I just need the syntax to refresh the grid. Thanks in advance for your advice!
if e.recordcount = 0 .and. eval_valid("session.SESS_SEQ") then
dim fai_id as N
dim part_number as C
dim seq_number as C
dim sql as C
dim args as SQL::Arguments
' fyi, links passed from qtfai contain:
' e.rtc.links[1].fieldname = "FAI_ID"
' e.rtc.links[2].fieldname = "PART_NUMBER"
' e.rtc.links[1].value = contains value of fai_id
' e.rtc.links[2].value = contains value of part_number
if e.cn.BeginTransaction() then
fai_id = e.rtc.links[1].value
part_number = e.rtc.links[2].value
seq_number = session.SESS_SEQ
'e.handled = .t. 'override the auto generated sql with the following 'GET FATAL ERROR WHEN ADD THIS LINE
sql = "INSERT INTO QTFAINSPECT (fai_id, part_number, sequence_number, item_description, nominal, upper_limit, lower_limit, um) SELECT :fai_id, part_number, sequence_number, dim_description, nominal, upper_limit, lower_limit, um FROM partdim WHERE part_number = :part_number AND sequence_number = :seq_number" ;
args.set("fai_id", fai_id)
args.set("part_number", part_number)
args.set("seq_number", seq_number)
if e.rtc.cn.execute(sql,args) == .f. then
e.flagerror = .t.
e.errorText = "Unable to update record at this time. [CONNEXEC4] "+ e.rtc.cn.CallResult.NativeText+" | "+ e.rtc.cn.CallResult.Text
e.rtc.cn.RollBackTransaction()
else
e.rtc.cn.CommitTransaction()
end if
end if
end if
session.RemoveAll()
end function
Comment