Hi expert,
I am trying to create the Global User Code so all my recording can use the same method. I have no issue creating the method in local recording, everything works as expected. I then try to reproduce the same user code and place it under the user code collection so my other recording can use it. I understand that I can copy the user code action from 1 recording to another and that will automatically generate the user code, but I would like to instead create the global if possible.
Under the local recording, I have the user code inside the method as the following:
string NewVariable = repo.WebInterface1.SearchFunction.RegisterCheckRow01Value.Element.GetAttributeValueText("InnerText");
I did some range check and report back the result, no issue, work perfect.
I tried to do the same thing duplicate the code under the Global user collection, during build process, I have the following error:
The name 'repo' does not exist in the current context (CS0103)
Any idea? Thanks in advance!!!
Global User Code
Re: Global User Code
Hi Sunny,
This error message means that the repository is not defined within the user code collection.
Just declare the repository directly in the user code collection with the following code.
After you have done this, you can access all elements in the repository like the way you did in the user code method.
Hope that helps.
This error message means that the repository is not defined within the user code collection.
Just declare the repository directly in the user code collection with the following code.
Code: Select all
var repo = NameOfYourRepository;
Hope that helps.
Re: Global User Code
Thanks, I did a test on it, it seems that I will have to create the NameOfYourRepository.Instance to get it working, If I don't have the '.Instance', it will report as an error 'NameOfYourRepository' is a 'type' but is used like a 'variable' (CS0118). It does gave me hint though and now my problem is solved.
On the other hand, I did try to bring in an Adapter as one of the Method parameter, it gives me flexibility to bring in any item from Repository.
On the other hand, I did try to bring in an Adapter as one of the Method parameter, it gives me flexibility to bring in any item from Repository.
asdf wrote:Hi Sunny,
This error message means that the repository is not defined within the user code collection.
Just declare the repository directly in the user code collection with the following code.After you have done this, you can access all elements in the repository like the way you did in the user code method.Code: Select all
var repo = NameOfYourRepository;
Hope that helps.