The issue related to retrieving the current record was scope. It is necessary to attach a method to the newly created form.
For the uninitiated, evt_onShow and evt_onHide code samples are included. The onHide method is required since I
added the newly created form to an existing tabpanel. The tab must be removed before the remove form method will
function correctly.
The evt_onShow method:
elements.tabs_extlData.readOnly = true
var fname = "testform"
var mname = 'myRecordSelection'
if (forms[fname])
{
var success = history.removeForm(fname)
if(success)
{
solutionModel.removeForm(fname)
}
}
if (!forms[fname])
{
//Create dataset
ds = databaseManager.createEmptyDataSet()
ds.addColumn("Degrees")
ds.addColumn("Direction")
ds.addRow([0, 'North'])
ds.addRow([45, 'Northeast'])
ds.addRow([90, 'East'])
ds.addRow([135,'Southeast'])
ds.addRow([180,'South'])
ds.addRow([225,'Southwest'])
ds.addRow([270,'West'])
ds.addRow([315,'Northwest'])
//Create a new data source, returns an uri that can be used to build forms on
var uri = ds.createDataSource('mydata', [DM_COLUMNTYPE.INTEGER, DM_COLUMNTYPE.TEXT]);
//Create form
var jsform = solutionModel.newForm(fname, uri, null, true, 760, 480);
jsform.navigator = SM_DEFAULTS.NONE
jsform.view = JSForm.LOCKED_TABLE_VIEW
jsform.newLabel("Degrees",0,0,100,19)
jsform.newLabel("Direction",100,0,200,19);
jsform.newHeaderPart(20)
var myField = jsform.newTextField("Degrees",0,20,100,20);
myField.editable = false;
var myField = jsform.newTextField("Direction",100,20,200,20);
myField.editable = false;
var myMethodString = 'function ' + mname+ '()'
myMethodString += ' {'
myMethodString += ' application.output("A direction of " + direction + " has a heading of " + degrees + " degrees.");'
myMethodString += ' }'
var myMethod = jsform.newFormMethod(myMethodString);
myMethod.showInMenu = false;
jsform.onRecordSelection = myMethod
}
//Add newly created form to existing tab panel
elements.tabs_extlData.addTab(forms[fname],'CompassTab','Compass',null,null,'#000000','#BBCCEE');
The evt_onHide method:
elements.tabs_extlData.removeAllTabs()