Dynamically resetting repository items

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
KurtZ
Posts: 12
Joined: Fri Jul 12, 2013 2:24 pm

Dynamically resetting repository items

Post by KurtZ » Fri Jul 12, 2013 3:06 pm

Background:
I have a multi-tab form used for performing searches. Each tab contains basically the same objects, with the only difference being the tab's index. I am creating rooted folders in my repository. Rather than create 5 folders containing the same 20 objects (100 total objects), I want to create 1 folder with 20 objects and set/reset the folder based on which tab I need to use.

Issue one:
When resetting the repository path of my rooted folder, my change is being appended to the current path as opposed to updating it.
string PathOriginal = RepoPath.VariableTab.SelfInfo.AbsolutePath.ToString();
//Reset Path
RepoPath.VariableTab.SelfInfo.Path = "container["+i+"]";
string PathUpdated = RepoPath.VariableTab.SelfInfo.AbsolutePath.ToString();

//I am getting
PathOriginal = "form/element/container"
PathUpdated = "form/element/container/container[2]"

//I am expecting
PathUpdated = "form/element/container[2]"
Issue two:
The update is not being applied to items nested inside the folder.
string ChildPathOriginal = RepoPath.VariableTab.textbox_IDInfo.AbsolutePath.ToString();
//Reset parent folder's path
RepoPath.VariableTab.SelfInfo.Path = "container["+i+"]";
string ChildPathUpdated = RepoPath.VariableTab.textbox_IDInfo.AbsolutePath.ToString();

//I am getting
ChildPathOriginal = "form/element/container/.//text[@name='id']"
ChildPathUpdated = "form/element/container/.//text[@name='id']"

//I am expecting
ChildPathUpdated = "form/element/container[2]/.//text[@name='id']"
Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Dynamically resetting repository items

Post by Support Team » Tue Jul 16, 2013 9:47 pm

Hello,

Thank you for providing your code snippet.
I think it would be easier to use repository variables instead of changing the absolute path of your repository element?
Please read the "Using Variables within the Repository" section in order to get more information how to create and use repository variables.
Thank you!

Regards,
Bernhard
.
Image

KurtZ
Posts: 12
Joined: Fri Jul 12, 2013 2:24 pm

Re: Dynamically resetting repository items

Post by KurtZ » Wed Jul 17, 2013 12:32 pm

Thanks Bernhard.

Unless I'm missing something, the problem with making the repo path variable as you have suggested means I have to maintain yet another column of data in my data sheet. This isn't a huge sticking point, but it requires additional manual interaction instead of having a snippet of code that does the work for me.

I could also use variations of Find to create my objects at runtime, but that defeats the purpose of having a repository.

It seems like resetting the repo item's path through code could work, it's just not working correctly.

Any other suggestions?
Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Dynamically resetting repository items

Post by Support Team » Fri Jul 19, 2013 12:50 pm

Hello,

In general, a rooted folder uses the Base path.
Could you please try the set the Base path instead of the path of your rooted folder?
RepoPath.VariableTab.SelfInfo.BasePath = "container["+i+"]";
Regards,
Markus (T)
.
Image

KurtZ
Posts: 12
Joined: Fri Jul 12, 2013 2:24 pm

Re: Dynamically resetting repository items

Post by KurtZ » Fri Jul 19, 2013 4:41 pm

BasePath exists on the folder object itself, as opposed to the SelfInfo object, but this solved both issues.
Thanks Rano team, you all rock!
RepoPath.container_VariableTab.BasePath = "container["+i+"]";