KevinVM's avatar
KevinVM
Established Member
16 days ago
Status:
New Idea

Building up NameMapping in Script recordings

I have the following objects in my NameMapping repository:

Aliases.App.MainForm.MdiClient.GridForm.AutoHideContainer.SelectionPanel.SelectionPanelContainer.grbSelection.GridForm_SelectionGrid

Aliases.App.MainForm.MdiClient.GridForm.AutoHideContainer.SelectionPanel.SelectionPanelContainer.grbSelection.GridForm_SelectionGrid.Row_19.Janus_Selector

Let's say I also add row 20 or another row in the Name Mapping repository:

Aliases.App.MainForm.MdiClient.GridForm.AutoHideContainer.SelectionPanel.SelectionPanelContainer.grbSelection.GridForm_SelectionGrid.Row_20.Janus_Selector

Problems:

Problem 1: Now I want to build up a NameMapping object string and perform actions on it(so it would click row 19 or 20) using variables.

//Returns value = 19 as rowIndex and stores it in rowIndex variable

var rowIndex = Aliases.App.MainForm.MdiClient.GridForm.AutoHideContainer.SelectionPanel.SelectionPanelContainer.grbSelection.GridForm_SelectionGrid.cSelectedRowIndex;

//The below object is also NameMapped in my NameMapping repository and I try to build up the Alias Object/String, so a sort of dynamic Alias, where you can assign any value to the variable rowIndex, reducing the need of hardcoded numbers in Aliases or different Aliases of all of the rows.

var janusSelector = "Aliases.App.MainForm.MdiClient.GridForm.AutoHideContainer.SelectionPanel.SelectionPanelContainer.grbSelection.GridForm_SelectionGrid.Row_"+rowIndex+".Janus_Selector";

Problem 2: When this "dynamic" NameMapping object is build up, no intellisense was available for the variable janusSelector, such as click methods etc.

After contacting support, they told me to create a NF request.

1 Comment

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    When using Aliases, it's best to try and shorten the name e.g. Aliases.GRBSelection.SelectionGrid as it's easier to script and maintain.

    It's also best to refer to, if possible, rows and columns or cells, as opposed to creating name mappings for each row. For example, Aliases.GRBSelection.SelectionGrid.Cell(19, 1).

    When doing var janusSelector = "Aliases.GRBSelection.SelectionGrid" + rowIndex + ".Janus_Selector"; you're assigning a string to a variable. Since it's not an object, intellisense will not understand it - it's basic intellisense!

    You can use the eval() function to evaluate the string and return its complete value. For example, var janusSelector = eval("Aliases.GRBSelection.SelectionGrid" + rowIndex + ".Janus_Selector"); will return the actual object.