![]() |
| |||||||
Automation Anywhere Post messages and questions related to Automation Software here. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| |||
|
I have a task lets say, mainTask, that runs another task say, subTask. If in the mainTask I have a variable, eg myTaskVar = 77 I wish to pass this value at runtime to the subTask - ' I had assumed that variables were in fact 'global' but it appears that each task uses an instance of variables.dat. - Suggestions welcomed |
| |||
|
Hello, Yes, you are correct. There are two ways by which you can pass parameter to sub task. 1) If you want to pass a single parameter, then use system variable, $Clipboard$. Before you call a sub task, assign value that you want to pass to $Clipboard$ using Variable Operation command. In sub task, assign value of $Clipboard$ to any variable using Variable Operation command. Similarly, if you wish to return value from a sub task then assign return value to clipboard and use it in the main task. 2) Create a variable that reads value from a text file lets say $GlobalVar$. Using 'Log To File' command update value of $GlobalVar$. You can use this variable in any number of sub tasks. The value of $GlobalVar$ will not change until you update the text file. Hope that helps. |
| |||
|
If using the $Clipboard$ variable, do you risk it being written to by another operation that sets the $Clipboard$ value? For example, if I have 50 tasks running at the same time, all of them with sub tasks that set a variable to the clipboard to pass values back to the parent task, could the value be overwritten before it is read by the parent task and thus cause problems? Thanks! |
| |||
|
It looks like passing parameters to sub tasks is possible in AA 5.5, but passing them back to the parent task is the problem. I was thinking about how to get around the clipboard and file issue (of overwriting your value) if several tasks were running at the same time and I came up with this (not tested). Create a GUID in the parent task and pass that to the child. Then in the child, you can create a txt file to store items to you want to pass back to the parent... just name the txt file using the GUID that was passed into it... then you know that each time the task runs (even if it's running simultaneously) you are able to pass variables between sub and parent tasks with confidence. Then you would delete the txt file at the end of your task to prevent getting a bunch of them. Just a theory... haven't tried it out myself but I don't see why it wouldn't work. For a GUID, you could probably just use the random variable generator built into AA. Just set it to give a number between 1 and 999999999999 (as many 9's as it will accept). While that is not as good as a true GUID, it is probably good enough! |
| |||
|
Hello, Using Automation Anywhere, you can certainly return the value back to the parent task using 'Log to File' command as suggested in previous post. If you need to run several tasks simultaneously and need to log the data in same file at the same time then it may cause the access violation issues. However, to get around this issue what you can do is, create a table say GlobalParameter in Access Database with three fields, Parent Task Name, Child Task Name and the Value Field. Now, in child task using 'Database: Insert SQL Statement' command you can insert the row into this table and log the data that you need to return to parent task. In parent task using 'Database:Select SQL Statement' command you can retrieve the logged value from GlobalParameter table. For your reference, we have created a sample task. To run this task, . Please copy .atmn files under location, 'C:\...\My Documents\Automation Anywhere\Automation Anywhere\My Tasks' folder. . Copy .mdb file under C:\. Hope that helps. |
| |||
|
thanks, I was thinking if you named your file using the guid which is created each time the task is run you wouldn't have that problem. I like your idea of using the database which is actually what I have implemented for logging myself... I just thought for others that don't want to connect to a database, the guid named log file might help. |
![]() |
| Thread Tools | |
| Display Modes | |
| |