Hi....
I have been searching around and found a thread about copying/duplicating a record and populating a new record with the information. I took that and tried to make it work with what I'm doing. Here is what I'm trying to accomplish:
1. User clicks a button to pre-fill in certain fields in a repeating section.
2. Upon click, an ajax callback is performed (see below) called getTemplateData
3. It takes a series of rows from a database table and creates/fills in defaults for fields in multiple repeating rows.
Here is screenshot of my form:
alpha_repeatingrowsissue.png
In the database, the below routine will read and is supposed to set a value to two dropdown boxes (question group and question).
Nothing is getting placed in the fields, however it is creating the proper number of rows in the repeating section.
I'm sure this is something simple and wrong with the code but I have no idea how to fix.
Here is the code:
I have been searching around and found a thread about copying/duplicating a record and populating a new record with the information. I took that and tried to make it work with what I'm doing. Here is what I'm trying to accomplish:
1. User clicks a button to pre-fill in certain fields in a repeating section.
2. Upon click, an ajax callback is performed (see below) called getTemplateData
3. It takes a series of rows from a database table and creates/fills in defaults for fields in multiple repeating rows.
Here is screenshot of my form:
alpha_repeatingrowsissue.png
In the database, the below routine will read and is supposed to set a value to two dropdown boxes (question group and question).
Nothing is getting placed in the fields, however it is creating the proper number of rows in the repeating section.
I'm sure this is something simple and wrong with the code but I have no idea how to fix.
Here is the code:
Code:
function getTemplateData as c (e as p) dim cn as SQL::Connection cn.open("::Name::dbConn") dim sqlCommand as C sqlCommand = "SELECT * FROM interactions_questiontemplates_items WHERE interactions_questiontemplates_items_templateid = 1" 'debug(1) dim cnt as n = 0 if cn.execute(sqlCommand) then dim rs as SQL::ResultSet rs = cn.ResultSet while rs.nextrow() cnt = cnt + 1 eval("j.INTERACTIONDETAILS_QUESTIONGROUPID" + alltrim(str(cnt))) = rs.data("interactions_questiontemplates_items_questiongroupid") eval("j.INTERACTIONDETAILS_QUESTIONID" + alltrim(str(cnt))) = rs.data("interactions_questiontemplates_items_questionid") end while 'JavaScript returned to dialog vjscmd = "{dialog.object}._setRepeatingSectionRowCount('CONTAINER_1'," + cnt + ",true,true);" 'Here we use the populate method and insert and convert our "j" pointer variable to javascript array vjscmd = vjscmd + "{dialog.object}.populate(" + varToJSON(j) + ",1,false,true);" 'this is adding the code to the above to create a new record and then wait 1 second before populating it. vjscmd = "{Dialog.Object}.newRecord();setTimeout(function(){" + vjscmd + "},1000);" else vjscmd = "alert('No details found for this layout');" end if cn.close() 'debug(1) getTemplateData = vjscmd end function
Comment