getFields in inherited form

Hi,

I have a custom excel export button in my application which makes excel exports from the active form.
Overall it works great, except for 1 specific form.
In the debugger I noticed that following lines of code are the problem :

var _js_form = solutionModel.getForm(_form)
	var _js_fields = _js_form.getFields()

_js_form contains following value…

com.servoy.j2db.scripting.solutionmodel.JSForm@13decf9 {
borderType:null,dataSource:"db:/globis_development/salesorderline",defaultPageFormat:null,extendsForm:com.servoy.j2db.scripting.solutionmodel.JSForm@1b10558,height:480,
initialSort:null,name:"overview_salesorderline_lst",namedFoundSet:null,navigator:null,onDeleteAllRecordsCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,
onDeleteRecordCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onDrag:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onDragOver:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onDrop:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onDuplicateRecordCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,
onElementFocusGained:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onElementFocusLost:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onFindCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onHide:null,onInvertRecordsCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onLoad:null,onNewRecordCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onNextRecordCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onOmitRecordCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onPreviousRecordCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onPrintPreviewCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onRecordEditStart:null,onRecordEditStop:null,onRecordSelection:null,onResize:null,onSearchCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onShow:null,onShowAllRecordsCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onShowOmittedRecordsCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onSortCmd:com.servoy.j2db.scripting.solutionmodel.JSMethod@1c387e0,onUnLoad:null,paperPrintScale:100,rowBGColorCalculation:"globals.sys_tableview_colors",scrollbars:0,serverName:"globis_development",showInMenu:false,styleClass:null,styleName:"globis_tableview",tableName:"salesorderline",titleText:null,transparent:false,useSeparateFoundSet:false,view:3,width:1000}

_js_fields is just blank, but my form is full of fields ??
It’s important to say that this specific form is inherited from another form. Is this the cause of my problem? If so, what can I do about it?

Thanks in advance

Robrecht

The solutionModel is the blueprint of your form (as you made it in the designer), but inheritance happens at runtime. So the solutionModel isn’t aware of the inherited fields on your form.

To get around this, you can either:

  1. In the solutionModel check if your form is extending another form and also get the fields from that superform.
  2. Don’t use the solutionModel, but get the fields using the elements array of your form. Note that this will get you all elements, including buttons, tabpanels, etc. You can use elements[yourelement].getElementType() to make sure it is really a field.

Hi Joas,

I got around it by using your first option :

if(_js_form.extendsForm != null) 
	_js_fields = _js_form.extendsForm.getFields()

Thanks a lot !!!