I’ve met several times this problem. I thought the default value was a great tool to avoid some ‘Assign’ activities but it seems it doesn’t.
My problem is the following:
I have a string variable called A with a default value equals to “First_Name”+“_”+B B is a string variable aswell. It doesn’t have a default value.
So I’ve set an input dialog activity to assign a string value to variable B. Let’s say B = “Something”.
Since I’ve said that the default value is “First_Name”+“_”+B, I’m expecting that when I’m using the string variable A, its value is “First_Name_Something”.
→ I do not use an assign activity to set A.
Actually, the output of A is First_Name_, ignoring the default value.
And I verified the B value with a write line activity (which has got the correct value I’ve set).
Looks like the default value is not supporting dynamic values but only hardcode.
So my question is : why does the default value of A is not taken into account the B value ?
Of course ! Here it is : TestUiPathForum.zip (39.6 KB)
Let me know if it’s not working. I just zipped the folder as it is.
@ppr : I’m not sure to fully understand what 's the difference of using a variable “byreference” and “byvalue”.
Is there a workaround in this case ? Should I set something in the parameters ?
And what is the point of default value if it’s not possible to link variables togheter ?
Is it just for hardcoding ?
In the above image the A is initialized with a default value. So when the code executes then It reads the variables and arguments first and then the code gets to execute. So in your scenario the B is initialized will null value so that’s why the B value printing as empty in “First_Name”+B. The input dialogue box is later so that’s why the B value is not getting printed in the First log message.
So if you want to print the B value in first log message then you need to assign a default value for B also as shown below and also the Value B should be kept above the Value A