On my form (call_dtl) i have a field (call_customerid) linked to a valuelist with customers. Next to it I have a button to show the detailform of the selected customer.
I want to create a generic OnAction eventhandler so i can use the same event for similar fields. I can show the correct program, but i’ve got some problems setting the foundset of that program to the correct record.
for the above example it is called using the folowing parameters:
- _program = ‘customers’
- _fld = ‘call_customerid’
NB: The id field of the customertable = ‘customer_id’
/**
* Perform the element default action.
*
* @param {JSEvent} _event the event that triggered the action
* @param _program the program needed to show
* @param {JSField} _fld the field that contains the id of the record that has to be shown
*
* @properties={typeid:24,uuid:"1E80FED4-43A5-48D7-BA05-987D8625ED7C"}
*/
function ShowSelected(_event, _program, _fld)
{
if(globals.nav.mode != 'browse') return; // no navigation in find and edit
if(!globals.nav.program[_program] || globals.nav.program[_program] == undefined) return
if(_fld == undefined) return; // no value to show
globals.nav.history = new Object()
var _template = globals.nav.template_types[globals.nav.program[_program].view]
var _form = globals.nav.program[_program].form[forms[_template].has1()][2]
// show the program
var _return = globals.svy_nav_showForm(_form, _program);
// sort the tables
if(_return == -1)
{
return
}
if(_return[0])// only if there are tabs
{
forms.svy_nav_base.dc_sort( _return[0], _return[1]);
}
// find the record
if(forms[globals.nav.form_view_01].controller.find())
{
forms[globals.nav.form_view_01]['customer_id'] = 'D8A05953-6ED8-4384-8C9C-915E2351EE0A' // <== how do i make this use the _fld parameter??
forms[globals.nav.form_view_01].controller.newRecord()
forms[globals.nav.form_view_01].controller.search()
}
}
For now this function is in call_dtl.js, but eventually has to be moved to globals. When i debug my code i can get the element details in interactive console:
=>elements[_fld]
TYPE_AHEAD[name:call_customerid,x:310,y:40,width:220,height:20,value:D8A05953-6ED8-4384-8C9C-915E2351EE0A] {bgcolor:“#ffffff”,caretPosition:0,editable:false,enabled:true,fgcolor:“#000000”,format:null,readOnly:true,toolTipText:null,transparent:false,visible:true}
I can see it has a value, but elements[_fld].value returns Undefined.
Jos