How to change a variable's value in a list or a table?

I get a table variable from a excel, now I want to modify some values in this table and then write back to the excel.
How should I do?
Thanks!

1 Like

Hi @yangyanz can you provide more details:

  • what data do you want to change?
  • maybe, you can share a sample excel file?

Dear, simply to say, I want to change a value of a table element, how to do that ?

I want to change an element’s value in a table/list variable

Hi @yangyanz

Sorry for delay.

It is possible to do it using a custom action

For Table:

If you store the new value in a string variable:

@CustomScriptAction(
    input = ['my_table', 'my_string'],
    output = 'my_table'
 )
 
def customScript() { 

   my_table.put(2,3, my_string) //replaces the 3rd element in the 2nd row with the value of variable ${my_string}
} 

If you define new value through text:

@CustomScriptAction(
    input = ['my_table'],
    output = 'my_table'
 )
 
def customScript() { 

    my_table.put(1,1, "Hello world!") //replaces the 1st element in the 1st row with the text Hello world!
}

For List:

@CustomScriptAction(
    input = ['my_list'],
    output = 'my_list'
 )
 
def customScript() { 

    my_list.putAt(5, "Hello world!") //replaces the 5ths element in the list with the text Hello world!
}

Hope it helps

this is not easy to use, can we make a new feature that allow us to operate the value in a table/list directly?
Table variable A, set A(x,y) = string/number/etc… variable B
note x and y can also be a variable in a loop.
So, with this new feature, we can use table/list function more powerful.
Thank you very much.@ashapkina

2 Likes

@yangyanz Thank you. I have added it to feature requests.

Vote for this topic to raise its priority.

I have figured out :thinking: how to do it to some extent. The script below does remove the “.0” that I get at the end of the strings from the A-cells in Excel.

The code could probably be much better, but I can not even make a copy of my project in RPA. This was the last stuff that kind of worked. :grinning:

The ide of the code below is that it removes “.0” from every Element in the Table, that was created from the range in Excel, from witch I copy it, one of the strange things with this is that it is not “.0” that has to be removed but [.]:

@CustomScriptAction(

input = [‘var_range_a’,],

output = ‘var_range_a’

)

def custumScript() {

String var_text

String var_text_mod

for (int i=1;i<5;i++){

var_text = var_range_a.get(i,1)

var_text_mod = var_text.replaceAll("[.]","")

var_range_a.put(i,1,var_text_mod)

}

}

1 Like

Now it actually only removes, what is more logical, only the “.” but I now just let the robot remove the last tkn that it writes. It now becomes:
50110
50120
50130
50140
But when the RPA writes the text in I put an extra step that do BACKSPACE on the last zero.

It would probably be handy if there could be some built in FUNCTIONS like in excel for doing this on a special row, column, or table in RPA. Functions like TRIM, CONCAT, LEFT, MID, RIGHT and so forth could be very handy.

I think some kind of enviroment for scripting would be nice to.

A logg-window and the usage of Stop and Steep by step, in the code where you could se all the values in the variables in use.

Some kind of more user friendly instructions as well, the most useful things with examples.

Hi every one …
Actually i have one list variable and in that variable i stored some name and email id ,from that list variable i want to remove all email id . is there any ways to do this. please help me.

Thank you.

You can create another list variable and use If condition to only copy the named IDs in it (see how to use it here), and then use that list variable in the script in stead of the first one.

Thank You…

1 Like

I have one more problem any one help me…

Actually i am get some name from web table into a list variable and i want to separate each name (i.g:- first name and last name) into tow string variable . i want to store first name into one string variable and last name into another string variable .

Thank You…

You can use Substring between actions for each name in the list, to get the text before the space (first name) and after the space (last name).

Thank You so much…

Hi…
Actually i get some name from web table and stored it in to excel sheet again i get all name from excel sheet to one list variable and compare those name to web table name, and if it is match then click those name in web table . how can i do this …

I’m wondering how to create a table in code or how to dynamicly add rows in code