Get Text returns same (old) data in for each loop

Dear everyone

I am having difficult trying to solve a specific problem.

I am using Navision to try to retreive some information about a company, either a company has an CVR number, a CPR number or BOTH, it can never be empty for both.

What I need to do is to check first, if the CVR number is filled out, if yes, then use the “Get” activity to retrieve the data (it’s all digits).

If CVR is empty, then go and look at the CPR number and retrive the data (also only digits)

Both CVR and CPR is a string consisting of only digits.

I need to do this with an X amount of companies, for now let’s just say there is 10 companies. I am using a for each loop and looping over my table with the companies name in Navision, one after the other to be able to see they information, hereunder if they have a CPR number or a CVR number.

Now, when I do this, for the first iteration it’s going good, I retrivede 3108782489 as a CVR number since CPR number is empty.
image

The problem is,that on the next iteration, when I want to retrive either CVR or CPR for the next company than the same data, “3108782489”, is being given which is the old CVR number for the previous company. I suspect this is because of not having dynamic selectors, but I want to hear you guys first.

Down below is the first company:

And down below is the second company but UiPath still returns the old CVR number “3108782489”:

If anyone can shine lights to why I keep on getting returned the old CVR number, then please do let me know. Thanks in advance.

Yours sincerely…
Mr. Bean

@nmjvk,

Try adding one Assign activity at the start of loop to reset the value of CVR number containing variable like this:

strCVRNumber = String.Empty

Thanks,
Ashok :slight_smile:

Just do Get Text on both fields and then you can look at the values in the variables to see which one is empty and which one is populated.

Dear Postwick

First of, sorry for late responds, I just now have got time to work further on this project. For some weird reason, even if I have two Get Text, one for the CVR number and one for the CPR number, there still is an annoying bug, where the program will save what is the previous number, and never update the new number. Do you want to see my workflow file? It is not that long

Dear @ashokkarale

I have tried that, however, it does not work

Here is an example:

First iteration - CVR number is ‘14818480’ therefor the number gets saved in “tempText

Second iteration - CVR number is not existing but the CPR number is, the CPR number is ‘19XXXXXXXX’ and SHOULD be saved in tempText however, when printing tempText it shows ‘14818480’ which is the old value/ data from the first iteration.

For every iteration “tempText” is ‘14818480’ and this is not desired.

Hey @nmjvk , any chance you could share the .xaml that has this problem?

I’d like to review the structure to be able to provide more info :slight_smile:

BR,
Ignasi

Dear @ignasi.peiris

Sure, here you go, take a look :slight_smile:

Subprocess - Indlæs_CVR_CPR_nummer.xaml (46.8 KB)

Also, please let me know if you need something translated. This is being built for a client and later given to them so the language is in Danish

Thanks! No need to translate, all good!

Couple questions:

  • Am I right assuming that there is no other page open with the same data in the background? Meaning, you only have 1 page open where the selector would be valid, correct? Trying to see if you might be navigating one page, but scraping from a different one.

  • You have the Log message to “tempText” before extracting it, I assume it was added in order to check if indeed it was coming with data or empty to debug - Could you also place one after the 2 Get Texts CVR to see if its coming empty, or for example with a white space in case the data is not showing on the app?

  • Last Hotkey activity - Send ESC - does not have a selector, linked to point 1, is it possible that it is acting on the active window, therefore closing it, but not acting on the expected one, and therefore leaving other screens open?

Dear @ignasi.peiris

Let me try to answer all your questions in the same order you asked them:

  1. Yes, you are assuming right. There is no other page open. Well, in Navision (the program where the data is located) opens up 2 other pages, however, thos are subpages. The structur would look something like this “Navision - Company information - CVR/CPR data”. With other words, when you click on Navision it opens up the application, click on “Company information” and it opens a new tab where “CVR/CPR” data is, click on “CVR/CPR data” and you can see the data that I need.

  2. I have placed the Log message “tempText” before exctrating excatly to make sure if, in fact, that the data was empty. I also added log afte the Get Text activity. The data is showing up after the “Get Text” activity, but it appears to ALWAYS be the same number

  3. Lastly, Hotkey activity - Send ESC - is linked up with the subpage “CVR/CPR data” in order to exit the page and get ready to enter the next companies information to be able to extract it’s CVR/CPR number. It works on our production machine, so I think we would not touch that for now :smiley:

Ps. I see I put 2 Get Text activity right after one another, my fault, you can just delete one of them, no need to extract the same data twice.

Furthermore, I have tried to include two screenshots so you cans ee what the log says. The log correctelly prints out the CVR number for the first business, but all business after that have different CVR/ CPR number, yet, the log keeps returning the same old CVR number from the first company

FIRST ITERATION OF FOR LOOP:

SECOND ITERATION OF FOR LOOP:

Hi @nmjvk ,

Could you maybe try using Breakpoints on Get Text activity, so you could check at each step what is the output of it ?

Also, Could you provide Screenshots of the Selectors for CVR case for two different transactions and also for the CPR case for two different transactions ?

I believe we might need to check whether the selectors of the previous transactions are still valid and available within the page and hence it is able to retrieve it.

Another method would be to check with Get Attribute activity with attribute as innertext/ aaname / outertext would help you retrieve the value correctly or not.

The problem seems to be with the Get Text activities, from a design perspective they should work and something is keeping the old variable value…

We can simulate the same functionality of the Get Text activity with a different one, called Get Attribute, to check if it might be a problem related to a glitch/bug on your version.

Please set it up as follows:

Activity Name: Get Attribute
Selector: Same as both Get Texts - CVR and CPR
Attribute: "text"
Output: temptext

This should extract the text in the same way a Get Text would do, but directly pointing to the attribute, and if it works, we can disregard selector issues, multiple page issues…

BR,
Ignasi