Code to extract a specific text from a Get Attribute Variable

Hi All, I need to extract File names from a CRM website and enter the details in another website. So I have used For each Ui element as all the file names are present in a single field in CRM and later I have used Get attribute activity to capture the data in a variable and AAname is selected. Now I need to select a particular file name only (for example. if the file name contains “Year 10”) to enter into a type into activity! Is there any code that selects specific data which can be used to enter into type into activity ?

@yeshwanth

You need to use if condition
In that filename contains “year 10”

Then pass that variable in the type into activity

Hope this helps

It sounds like you’d be better of using Table Extraction to get all the data into a datatable, then Filter Data Table to keep only the values you want, then For Each through the remaining rows of the datatable and enter into the web site.


this is the method I have used and what can be the variable to pass in the type into activity ?

@yeshwanth

Below the get attribute use if condition

condition

Filenames.equals(“Year 10”) or Filenames.Contains(“Year 10”)

Then

inside of then use type into activity pass the variable as filenames

hope this helps

unfortunately, it didn’t work :frowning: maybe because the get attribute activity and if condition is in different use application activity

@yeshwanth

No problem you can use classic type for that in place of modern

Or else

Fine tune the use application activity of type into

I have used this, but didn’t work

@yeshwanth

Can you share the value of the filename which you are getting

Have fine tuned the selector
If fine tuned can you please share the both use browser selector which you are using

image

I get the values in this way,the name keeps changing but the word “Year 10” exists. I didn’t u understand the term fine-tuned, can you please elaborate, I am a beginner to UiPath

@yeshwanth

Can you use another assign

Above if activity

Newvariable=path.getfilenamewithoutextension(filenames)

Gives you the output as

Vidya sami year 10

Use newvariable in the if condition

Like
newvariable.contains(“year 10”)

image

I am getting this as the output for newvariable and the file names are given below which I am extracting
image

@yeshwanth

It will give you the file name just without .pdf

You can you that in if

Condition

If it contains moves to then

If it not contains moves to else block

this worked If I create activity like this

Though there are 4 other file names, UiPath is taking only a file name with IELTS

@yeshwanth

if condition
it will execute only the file name contains IELTS

if you want to execute for all other filenames

please let me know what you are expecting

Hope this helps

it should extract all the filenames and in type into activity , it should type the file name which contains “Year 10”, and for another type into which contains “Year 12” so on

@yeshwanth

Create array of string like below

arr_str={“Year10”,"Year12,“UG”,“PG”,“IELTS”}

and if condition

use below code

arr_str.Any(Function(x) x.ToString.Contains(newvariable))

it will give true value if there is any value

in then

use Type Into activity

inthat pass newvariable

Hope this helps

it is showing an error

@yeshwanth

can you check the datatype of arr_str

and place it above of for each uielement

placed it above for each uielement but the activity is not getting executed as it is showing an error