JSForm getDesignTimePropertyNames

Questions and answers for designing and implementing forms in Servoy

JSForm getDesignTimePropertyNames

Postby tkilshaw1553613063 » Fri Mar 15, 2024 9:08 pm

I added some design time properties to my form.

When a button is clicked it does this in the form's JavaScript:

function onAction$PrintForm( oEvent )
{
...
/** @type {JSForm} */
var oForm = forms[controller.getName( )];
var test = oForm.getDesignTimePropertyNames();
...
}

I get this error:

ERROR com.servoy.j2db.util.Debug - TypeError: Cannot find function getDesignTimePropertyNames in object FormScope__20005_Generic$UCDA_UsedBOS_2015[iNumberPayments,dBuyerInsExpiryDate,makeCertNumber,sToS_06Label,nToS_13,sLoeX,sDescribe10,nToS_12,sDescribe11,nToS_11,sDescribe12,nToS_10,nToS_19,sToS_21Label,doToS_28_TotalBalanceDue,nToS_17,nToS_16,nToS_15,nToS_14,getCertTypeValuelistData,gsFormName,sUnitP_StockNumber,incCertIndex,doGetNames,sBuyerInsAgentPhone,nToS_24,getFormNameAndNumber,gaCertColNames,nToS_23,nToS_22,nToS_21,sUnitP_Trim,nToS_20,sOdomKMx,gsFormNumber,nToS_27,nToS_26,nToS_25,sDescribe4,sToS_11Label,splitTradeOdometer,sDescribe5,sDescribe2,sDescribe3,sDescribe1,nLien,dDealDate,sDescribe8,sDescribe9,sDescribe6,sDescribe7,setVarsFromRelations,nToS_01_SellingPrice,sToS_16Label,sCobuyerFML,checkDealCertStatus,dBuyerDLExpiryDate,controller,sToS_04Label,gsParentFormName,doToS_23,doToS_22,doOdometerMIx,doToS_21,doToS_20,sToS_23Label,doToS_27,doToS_26,doToS_25,doToS_24,doBuyerAddress,dFinanceFirstPmtDate,makeDateField,sBusDealAddress,sOdomTradeMIx,iCB8,splitTradeVIN,iCB9,sUnitT1_Model,getTextAlignmentFromStyleClass,addPrintPromptFormRecord,getTemplateRecord,sDepositTypeCredit,sBuyerCity,sUnitT1_Color1,iCB1,iCB2,_formname_,iCB3,iCB4,sToS_13Label,iCB5,sBuyerInsAgent,sUnitT1_Trim,iCB6,iCB7,gsCertStatusMessage,sStateProvince,sToS_27Label,doDepositTypes,prePrintCertificateStuff,dDate1,sBuyerInsPolicyNum,sLifeX,makeAppliedRecord,isFontItalic,refreshRelations,doBusDealAddress,isFontBold,nFinanceRate,sToS_03Label,sSalespersonFLNames,foundset,dDate2,iUnitT1_Year,dDate3,sToS_02Label,sToS_08Label,sUnitT1_Make,doOdometerTradeKMx,isParentElement,onShow,sDisX,sVIN8,sVIN9,sVIN4,nToS_02,sVIN5,sVIN6,openFormDialog,sBusDealPhoneFax,sVIN7,lockTemplate,sVIN1,sVIN2,sToS_12Label,sVIN3,nToS_08,nToS_07,nToS_06,nToS_05,sBuyerDLNumber,nToS_04,nToS_09_SubTotal_1,nToS_03,getFormatForTextField,sUnitP_Color1,unlockTemplate,sLienPayee,sUnitP_Model,getColumnValue,nRVIfWarrInSP,sCiX,sToS_22Label,savePrintPromptFormFields,gbCertIsForLOEOnly,sToS_19Label,doFinancePaymentDisplay,onAction$ClosePrintPromptForm,sToS_05Label,sToS_24Label,sBuyerAddress,sOdomMIx,doToS_01_SellingPrice,sVINTrade2,sVINTrade3,gsParentListName,sVINTrade1,sVINTrade6,nFinancePaymentDisplay,sVINTrade7,sVINTrade4,sVINTrade5,sVINTrade8,sVINTrade9,iCB10,onAction$GenerateJRXML,iCB17,iCB16,iCB15,onAction$PrintForm,doOdometerKMx,iCB14,sToS_17Label,iCB13,sBusMain_DealerNumber,iCB12,iCB11,gbCertIsForAllInsTypes,sDepositTypeCash,sToS_10Label,sToS_07Label,getNewCertNum,sToS_20Label,isFontUnderline,doInsTypeDisCI,sAllNames,elements,sBuyerInsCompany,doToS_18_Subtotal_2,sToS_26Label,sOdomTradeKMx,doNumPmts,splitVIN,doBusDealCityProvPostal,onAction$ClearPrintPromptFields,sToS_14Label,doToS_12,doToS_11,doToS_10,sBuyerFMLorCO,doToS_09_SubTotal_1,doToS_16,doToS_15,doToS_14,doToS_13,iUnitP_Year,doToS_19,sVINTrade10,doToS_17,oScreenVars,sVINTrade12,sVINTrade11,sVINTrade14,sVINTrade13,makeTextField,getFontSizeFromStyleClass,makeCheckbox,sOdometerTrade5,showFormCompleteMsg,sOdometerTrade4,sOdometerTrade3,sOdometerTrade2,sOdometerTrade6,doToS_05,sOdometerTrade1,doToS_04,doToS_03,doToS_02,doToS_08,sDepositTypeCheque,doToS_07,doToS_06,sTax1Number,setChildFormFieldValuelist,sCompanyDBA,sBankName,jsonParseAndFix,sToS_25Label,showBePatientMsg,sDealNumber,doOdometerTradeMIx,doDepositType,doSalespersonFLNames,sVIN14,sVIN13,sVIN12,sVIN11,sCompanyName,makeJasperParamXMLFixVals,sVIN17,sVIN16,sVIN15,sBuyerPhone1,sBusDealCityProvPostal,nToS_18_Subtotal_2,sVIN10,sBuyerPhone2,sVINTrade16,sVINTrade15,sVINTrade17,sUnitP_Make,sOdometer1,setMainScreenVars,sDescribe17,updateDealsCert,sDescribe13,sDescribe14,sDescribe15,sDescribe16,sPostCode,doBankName,doInsTypeLifeLOE,sOdometer5,sToS_15Label,sOdometer4,nToS_28_TotalBalanceDue,postPrintCertificateStuff,sOdometer3,sOdometer2,gaTemplateRowVals,doBusDealPhoneFax,splitOdometer,sOdometer6]. (C:\Users\terry.QUANTECH\git_202006\qfi\qprint\forms\_20005_Generic$UCDA_UsedBOS_2015.js#1398) (Form Context: _20005_Generic$UCDA_UsedBOS_2015), JSEvent(type = action, source = Component: <'svy_1073758004' of parent FormUI for FormController[form: _20005_Generic$UCDA_UsedBOS_2015, fs size:100, selected record: Record[DATA:Row(db:/qfi/t_qprint)[DATA:id=C4SP3367ZYBUX7TNBG0Q,formnumber=20005,fk_companyid=SLZ2UQP2NC1HC36WUOCL,fieldsjson={"sUnitP_Color1":"Red","iNumberPayments":105,"dBuyerInsExpiryDate":{"javaClass":"java.util.Date","time":1704182400000},"sUnitP_Model":"D3","sLienPayee":"Lien Payee","sToS_06Label":"PROTECTION PKGS.","sCiX":"X","nRVIfWarrInSP":0,"nToS_13":null,"sLoeX":"X","sDescribe10":"","nToS_12":12227.17,"nToS_11":86213.43000000001,"sDescribe11":"","nToS_10":2476,"sDescribe12":"","nToS_19":2001,"nToS_17":321.88,"sToS_05Label":"BATTERY LEVY","nToS_16":333,"nToS_15":1343,"nToS_14":666,"sUnitP_StockNumber":"345987","sBuyerInsAgentPhone":"111-222-3333","sBuyerAddress":"44 Long Street, Suite 16","sOdomMIx":"","nToS_24":200,"nToS_23":522.1424000000001,"nToS_22":3218.8,"sUnitP_Trim":"Super","nToS_21":8785.65,"nToS_20":234,"sVINTrade2":"H","sVINTrade3":"G","sOdomKMx":"X","sVINTrade1":"1","sVINTrade6":"4","nFinancePaymentDisplay":1170.44,"sVINTrade7":"1","sVINTrade4":"B","sVINTrade5":"H","nToS_27":12129.69,"nToS_26":111596.07,"sVINTrade8":"J","nToS_25":111596.07,"sVINTrade9":"X","sDescribe4":"","iCB10":0,"sDescribe5":"","sDescribe3":"","sDescribe1":"","nLien":333,"dDealDate":{"javaClass":"java.util.Date","time":1677744000000},"iCB17":0,"iCB16":0,"iCB15":0,"iCB14":0,"sDescribe8":"","sBusMain_DealerNumber":"DN999","iCB13":0,"sDescribe9":"","iCB12":0,"sDescribe6":"","sDescribe7":"","iCB11":0,"sDepositTypeCash":"X","nToS_01_SellingPrice":86281,"sCobuyerFML":"","dBuyerDLExpiryDate":{"javaClass":"java.util.Date","time":1695279600000},"sToS_07Label":"","sToS_04Label":"TIRE LEVY","sAllNames":"Samantha Collins","sBuyerInsCompany":"Carling","dFinanceFirstPmtDate":{"javaClass":"java.util.Date","time":1678950000000},"sBusDealAddress":"123 Long Street","iCB8":0,"sOdomTradeMIx":" ","sUnitT1_Model":"Trade Model","iCB9":0,"sOdomTradeKMx":"X","sToS_14Label":"LICENCE FEE","sDepositTypeCredit":"","sBuyerCity":"Shortville","sUnitT1_Color1":"Magnolia","iUnitP_Year":2023,"iCB1":0,"iCB2":0,"sVINTrade10":"M","iCB3":0,"iCB4":0,"sVINTrade12":"1","sBuyerInsAgent":"Ins Agent","sUnitT1_Trim":"Trade Submodel","sVINTrade11":"N","iCB5":0,"sVINTrade14":"9","iCB6":0,"sVINTrade13":"0","sStateProvince":"SK","sOdometerTrade5":"6","sOdometerTrade4":"6","sOdometerTrade3":"5","sOdometerTrade2":"5","sOdometerTrade6":"6","dDate1":null,"sBuyerInsPolicyNum":"pn 3353","sOdometerTrade1":"","sLifeX":"X","sDepositTypeCheque":"X","sTax1Number":"GST1","sCompanyDBA":"Acme Widgits DBA","sBankName":"Bank of Montreal","nFinanceRate":5.123,"sDealNumber":"1428","sToS_03Label":"DOC. FEE","sSalespersonFLNames":"TERRY KILSHAW","sVIN14":"2","iUnitT1_Year":2018,"dDate2":null,"sToS_02Label":"EXTENDED WARRANTY","sVIN13":"7","dDate3":null,"sVIN12":"0","sVIN11":"C","sCompanyName":"Acme Widgits","sToS_08Label":"","sUnitT1_Make":"Trade Make","sVIN17":"6","sVIN16":"5","sVIN15":"2","sBuyerPhone1":"250-223-3334","sBusDealCityProvPostal":"Kelowna, BC, V3T 24U","nToS_18_Subtotal_2":189793.91000000003,"sVIN10":"C","sBuyerPhone2":"","sVINTrade16":"8","sVINTrade15":"1","sVINTrade17":"6","sUnitP_Make":"Ferrari","sOdometer1":"1","sDisX":"","sDescribe13":"","sVIN8":"A","sVIN9":"5","sDescribe14":"","sDescribe15":"","sPostCode":"V3U 5U8","sDescribe16":"","sVIN4":"F","nToS_02":400,"sVIN5":"R","sVIN6":"7","sVIN7":"Z","sBusDealPhoneFax":"Phone: 1-250-707-0622 Fax: 1-222-333-4444","sVIN1":"S","sVIN2":"C","sVIN3":"B","sToS_15Label":"Other Fees & Taxes","sOdometer5":"5","sOdometer4":"4","nToS_28_TotalBalanceDue":123725.76,"sOdometer3":"3","nToS_08":null,"nToS_07":null,"sOdometer2":"2","nToS_06":1486.21,"sBuyerDLNumber":"DLN333","nToS_05":300,"nToS_09_SubTotal_1":88689.43000000001,"nToS_04":200,"sOdometer6":"6","nToS_03":22.22}, CALCULATIONS: {}]] COLUMS: id,formnumber,fk_companyid,fieldsjson,getChangedData,getDataSource,getException,revertChanges,isEditing,save,getPKs,isNew,hasChangedData,rollbackChanges,isRelatedFoundSetLoaded,getFoundset,deleteRecord,,destroyed:false]>, formName = _20005_Generic$UCDA_UsedBOS_2015, elementName = <no name>, timestamp = 2024-03-15 12:01:25.475,modifiers = 0,x =1112,y = 17,data = null)
at C:\Users\terry.QUANTECH\git_202006\qfi\qprint\forms\_20005_Generic$UCDA_UsedBOS_2015.js:1398 (onAction$PrintForm)

Any idea what is wrong here?

thanks,

Terry
tkilshaw1553613063
 
Posts: 52
Joined: Tue Mar 26, 2019 5:11 pm

Re: JSForm getDesignTimePropertyNames

Postby mboegem » Sun Mar 17, 2024 3:23 pm

Hi Terry,

Things are mixed up in your code. As far as I can see there are 2 ways of retrieving the design time properties:
1) Through solutionModel
2) Through the form controller.

Your code is a mix of these 2, hence the error.
The reason that the code editor doesn't show you the mistake, is because you've overridden the oForm variable type with JSDocs (which should not be needed at all)

I guess either of 2 examples below should do the job:
Code: Select all
function onAction$PrintForm( oEvent )
{
...
var jsForm = solutionModel.getForm(oEvent.getFormName());
var aPropertyNames = oForm.getDesignTimePropertyNames();
...
}


Code: Select all
function onAction$PrintForm( oEvent )
{
...
var oForm = forms[oEvent.getFormName()];
var oProperties = oForm.controller.getDesignProperties();
var aPropertyNames = Object.keys(oProperties);
...
}


As you can see the first example will give you only the property names, so in order to get a specific property you need to call a 2nd function

The second example does contain the properties (both key & value) in the oProperties variable.

Hope this has unraveled your error mystery ;-)
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1765
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: JSForm getDesignTimePropertyNames

Postby tkilshaw1553613063 » Mon Mar 18, 2024 5:26 pm

Hi Mark!

thanks for this response. I should have mentioned that we are still using Servoy version 202006.

Your first example using the solutionModel to get the form from the event failed with the same error I had before:

var oForm = forms[oEvent.getFormName()];
var oProperties = oForm.controller.getDesignProperties();

ERROR com.servoy.j2db.util.Debug - TypeError: Cannot find function getDesignProperties in object Controller:_20005_Generic$UCDA_UsedBOS_2015.

Your next worked, using:

var jsForm = solutionModel.getForm(oEvent.getFormName());

So that's great. I still don't understand why my original code:

var oForm = forms[controller.getName( )];
var test = oForm.getDesignTimePropertyNames();

does not work. Any ideas?

cheers,

Terry
tkilshaw1553613063
 
Posts: 52
Joined: Tue Mar 26, 2019 5:11 pm

Re: JSForm getDesignTimePropertyNames

Postby mboegem » Mon Mar 18, 2024 9:41 pm

Hi Terry,

I don't think the version number is really the issue here.

Please look closely at the way the form is retrieved:

solutionModel.getForm(controller.getName()) or solutionModel.getForm(event.getFormName())

is not the same as

forms[controller.getName()] or forms[event.getFormName()]

The latter will give you a runtime form object, where the first one will return a JSForm.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1765
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: JSForm getDesignTimePropertyNames

Postby tkilshaw1553613063 » Mon Mar 18, 2024 10:46 pm

Thanks for your reply.

How is it that you know about this? Where can I read about when I will be getting a "runtime form object" instead of a JSForm?

thanks,

Terry
tkilshaw1553613063
 
Posts: 52
Joined: Tue Mar 26, 2019 5:11 pm

Re: JSForm getDesignTimePropertyNames

Postby mboegem » Mon Mar 18, 2024 11:35 pm

tkilshaw1553613063 wrote:How is it that you know about this?

About 17 years of Servoy experience ;-)

Apart from that, when using solutionModel you are dealing with the blueprint of your solution.
Either you are reading the original (designtime) state of your solution, or you are creating/modifying parts of your solution. Although executed at runtime, this should be compared with designtime changes.
Therefor the solutionModel is very powerful and besides using at runtime, it can be used to perform repetitive or bulk changes for a developer as there is a possibility to save these changes to your workspace in order to make them persistent.

Anything else can be considered runtime.
Referencing a form like form['myForm'], will already touch that form resulting in loading the form.
It does not make any difference if you use forms.myForm or var _sFormName = 'myForm'; forms[_sFormName]
Both result in runtime form.

The easiest way to see what the returned type is, is by looking at the documented type in the solution explorer.
Also hovering over your code can give you more information about the type (if the editor was able to work it out)

If you want to know more about solutionModel and its possibilities, this is probably a good starting point: https://wiki.servoy.com/display/DOCS/Solution+Model

Hope this helps a little bit.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1765
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: JSForm getDesignTimePropertyNames

Postby tkilshaw1553613063 » Tue Mar 19, 2024 5:10 pm

Great, thanks! I guess it might take me more than17 years to figure out some of this stuff using the Servoy documentation :-)

One more very naiive question. Where do I "look at the documented type in the solution explorer"? Particularly about finding out about the runtime form or JSForm behaviour that you have been explaining.

Cheers

Terry
tkilshaw1553613063
 
Posts: 52
Joined: Tue Mar 26, 2019 5:11 pm

Re: JSForm getDesignTimePropertyNames

Postby mboegem » Tue Mar 19, 2024 5:38 pm

tkilshaw1553613063 wrote:I guess it might take me more than17 years to figure out some of this stuff using the Servoy documentation

No way... just increase the number of hours spend on programming each day :lol:

As for these types

you can see JSForm mentioned here:
solution explorer.png
solution explorer.png (119.9 KiB) Viewed 3111 times


and RuntimeForm here:
tooltip doc.png
tooltip doc.png (19.51 KiB) Viewed 3111 times
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1765
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: JSForm getDesignTimePropertyNames

Postby tkilshaw1553613063 » Wed Mar 20, 2024 5:13 pm

Marc,

thanks for your patience.

I see that the first list is accessed using the SolutionModel item in the Solution explorer but where are you seeing the RuntimeForm information?

Terry
tkilshaw1553613063
 
Posts: 52
Joined: Tue Mar 26, 2019 5:11 pm

Re: JSForm getDesignTimePropertyNames

Postby mboegem » Thu Mar 21, 2024 8:57 am

The 2nd screenshot is taken from the code editor.
If you hover over the code, these are the tooltips you get.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1765
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Forms

Who is online

Users browsing this forum: No registered users and 5 guests

cron