VMware Cloud Community
Murugaas
Contributor
Contributor

find and findAll methods loading vRO inventory

Hi,

Trying a plugin for vRO..

While trying to insert some input parameter for a workflow , a text box gets created and for an action item, a search box gets created. Script for it is as below. Here, when search string is typed, for each and every character typing, find() is getting called to load corresponding objects. How to restrict it? And can't we direct the output of Action method to drop down instead of loading objects and searching on it as it taking more time?

 
 
 </p-param>  
       <p-param name="searchString">
        <desc><![CDATA[Search Name]]></desc>
        <p-qual kind="static" name="mandatory" type="boolean"><![CDATA[true]]></p-qual>
      </p-param>
      <p-param name="searchedCandidates">
        <desc><![CDATA[Search Candidates]]></desc>
        <p-qual kind="static" name="mandatory" type="boolean"><![CDATA[true]]></p-qual>
        <p-qual kind="ognl" name="linkedEnumeration" type="Array/<Dynamic Type>"><![CDATA[GetAction("<package name>","<methodName>").call( #connection , #searchString )]]></p-qual>
      </p-param>

 </p-param>  

       <p-param name="searchString">

        <desc><![CDATA[Search Name]]></desc>

        <p-qual kind="static" name="mandatory" type="boolean"><![CDATA[true]]></p-qual>

      </p-param>

      <p-param name="searchedCandidates">

        <desc><![CDATA[Search Candidates]]></desc>

        <p-qual kind="static" name="mandatory" type="boolean"><![CDATA[true]]></p-qual>

        <p-qual kind="ognl" name="linkedEnumeration" type="Array/<Dynamic Type>"><![CDATA[GetAction("<package name>","<methodName>").call( #connection , #searchString )]]></p-qual>

      </p-param>

Thanks,

Reply
0 Kudos
6 Replies
iiliev
VMware Employee
VMware Employee

Hi,

searchedCandidates is bound to an action that depends on searchString, so the action will get called on every change of searchString value. You cannot restrict this.

As for a dropdown, check if there is a property 'Select value as' for the presentation field.

Reply
0 Kudos
Murugaas
Contributor
Contributor

Thanks for the reply. Oh is that so. I thought something should be there as once typing is completed then the action item gets triggered.

Tried "Select value as" but not working as expected. Is it possible to return the objects of dynamic type directly to the drop-down list from action method?

Or we need to call find() or findAll() to load the dynamic objects to inventory. And then action method has to be called to search upon it? My requirement is to get a list of files based on a filename search. In the text field, filename string will be provided. In the search/drop down, action method is written to list the files - to search and select.

Thanks,

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

'Once typing is completed' could be interpreted differently by different people Smiley Happy Some frameworks provide 'focus in'/'focus out' events, when some events get triggered when the input focus is moved between input fields, but current vRO presentation does not have these events, only 'content changed' event.

In your case, action could return either Array/string (representing the list of names of the found files) or Array/<YourType> (representing the list of found files). Action is not aware of how this list will be presented in the UI.

Reply
0 Kudos
Murugaas
Contributor
Contributor

Thanks Smiley Happy. My doubt is do I  need to update the finder function findAll() or find() for this dynamic type or simply action method itself holds good to list the filenames?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

It is hard to say without knowing what exactly you do in find/findAll, but in general find/findAll are generic functions that finds object by its type and id, or finds all objects by their type, and they are written once.

Scripting action should just return an array with filename objects. vRO will automatically call find/findAll whem/if necessary.

Reply
0 Kudos
Murugaas
Contributor
Contributor

What I am trying to do is..

getting a filename string in an input text box of type String. While typing the filename in the input box, find() gets called and it is finding all files on the system/VM (find syntax is written for the custom type, hence it is called for filename input). find() gets called for each and every character..say if I want to type "text", it gets called 4 times, one for "t", another for "te" and so on.

If we did not define anything in find() for the custom type with only action method written, file objects are not getting loaded in the next following drop-down. It looks like we need to define the custom type in find()/findAll() to load them to search in the drop down. But it takes quite more time to fetch and list in the drop down ~10 minutes in smaller environment itself.

Probably I may miss something here, and not sure of an efficient way to get the file objects listed in drop down.

Any other input is needed to help me here?

Need is, to list custom file objects in drop down (query string is provided in the input)

Thanks,

Reply
0 Kudos