problem with onRender event in webclient

I am having problem with the onRender event in webclient.

function onRender(event) {
// TODO Auto-generated method stub

/** @type {JSRecorddb:/database_name/stock_items} */
var myRecordStock = event.getRecord();
var myStock = myRecordStock.stockcode;

I’ve placed the above onRender function in a text field on table view. When I run it in smart client, it works properly. However, when I run it in webclient, I got the following error message:

TypeError: Cannot read property “stockcode” from (F:\Servoy Projects\TestWebStuff\forms\commitlist.js#37)
at F:\Servoy Projects\TestWebStuff\forms\commitlist.js:37 (onRender)

Is it supposed to work only in smart client but not webclient?

I am using Servoy v7.0

Have you tried:

function onRender(event) {
// TODO Auto-generated method stub

/** @type {JSRecord<db:/database_name/stock_items>} */
var myRecordStock = event.getRecord();
if(myRecordStock {
var myStock = myRecordStock.stockcode; 
}

Hi All,

Yes, Harjo you are correct and the code snippet you have given will work. I have faced same issue and get ride of that by checking if record is exist before accessing the data.

Thanks
Chaitanya s

It is still not working. I have the feeling that “event.getRecord()” does not work in webclient. When I go to debug, the value generated by “event.getRecord()” is “Record”. However, when I debug in webclient, the value generated is “null”.

Can anyone please confirm that “event.getRecord()” does not work in webclient but runs beautifully in smart client?