Forum Discussion

kriz6912's avatar
kriz6912
New Contributor
9 years ago
Solved

Accessing object via string reference

Hi,

Currently I access the fields in MyObject in following manner:
var MyObject = Aliases.Device.Process_qv.RootLayout.Layout('NO_ID').ListView('profile_list');
var ButtonLabel = MyObject.Button("title", 1).mText;

I'm wondering if it also possible to store an object reference as a string and create an object of it when needed. This way I can maintain a centralized list of all object references.

var MyObjectRefString = "Aliases.Device.Process_qv.RootLayout.Layout('NO_ID').ListView('profile_list');"
var MyObject = ??? how to turn object string reference into an actual object ???
var ButtonLabel = MyObject.Button("title", 1).mText

Thanks!
  • Hi Kriz6912,

     

    You can use the eval function for this:

    var MyObjectRefString = eval("Aliases.Device.Process_qv.RootLayout.Layout('NO_ID').ListView('profile_list')");

2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Kriz6912,

     

    You can use the eval function for this:

    var MyObjectRefString = eval("Aliases.Device.Process_qv.RootLayout.Layout('NO_ID').ListView('profile_list')");
  • Hi - do you need to store the object refs as Strings?

     

    I store things like this in a unit and store them centrally and use them in multiple places:

     

    var catchmentProfileSearchBtn = catchmentProfilePage.panelPageTable2.asideCriteria.formSpcSearchForm.panelSpcSearchAccordion.panelJqSpcSearchOptionsContainer.buttonSearch;