Cannot find function getName in object

Can someone tell me what this means:

Cannot find function getName in object com.servoy.j2db.smart.dataui.DataRenderer[Body,0,0,1020x657,invalid,layout=com.servoy.j2db.util.gui.AnchorLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777225,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=1019,height=605]]

My users are running into it seemingly randomly.

This might be more helpful:

This:

if (utils.stringLeft(forms[currentForm].elements[elm].getName(), 4) == 'fld_') {

(where currentForm = “qs_quotes_dtl” and elm = “Body”)

gives me this:

“Error during evaluation:TypeError: Cannot find function getName in object com.servoy.j2db.smart.dataui.DataRenderer[Body,0,0,1020x657,invalid,layout=com.servoy.j2db.util.gui.AnchorLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777481,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=1019,height=605]].”

Can I assume my issue is with whatever is in the Body that is returning ‘invalid’ in the DataRenderer?

Hello Providence1,

It throws error because there are no such element with the name “Body” exists in the forms.
You can print elements.allnames and check elements for the forms. As a solution:

  1. We can check if the elements[elem] is instance of RuntimeComponent before proceeding.
  2. Unless we are doing some manipulations to the form at runtime, we do not need to attach the onRender event at form level. We can select multiple fields in the form and attach the same onRender event to the elements.

Hope this helps.

Thanks,
Lopamudra
lopamudram@mindfiresolutions.com

I just spoke with Johan Compagner and this is a bug that is fixed in 7.4.1 (now in RC).
It’s not specifically related to onRender but to events in general.

So I guess as a workaround you can check if the element is an instance of RuntimeComponent.
Checking for JSComponent or JSField doesn’t work. These classes are used on the blueprint, i.e. the Solution Model. Not in the actual runtime instance.
So the code could look like this:

var _aElements = elements.allnames;
for ( var i = 0 ; i < _aElements.length ; i++ ) {
    if ( elements[_aElements[i]] instanceof RuntimeComponent ) {
        // your code
    }
}

Hope this helps.

Yes, we need to check if element is instance of RuntimeComponent.
Thanks ROCLASI for rectifying.

Regards,
Lopamudra
lopamudram@mindfiresolutions.com