QueryView in a form returning not existing elements

hi,

i have a form and Initially i am adding a layout .

and after that i am deleting the layout using the below code

let remove = this.getParentView();
this.getParentView().getParentView().removeView(toRemove);

But the problem is when i am doing a component scan in the form

var layout = this.getParentView();
var richselects = layout.queryView({view:"richselect"},"all");

it is giving the me the component .But the component is not in the form i have deleted it .

How to get components that are present in the form…

Can someone please help?

Hi,

I got the answer . I placed it in wrong place in the code.