Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: Return dataset from task function
Topic Summary: How to capture return dataset from task function
Created On: 07/24/2018 01:34 PM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
 07/24/2018 01:34 PM
User is offline View Users Profile Print this message

Author Icon
PatrickMarshall
Student (5-19 posts)

Posts: 13
Joined: 06/14/2016

I am trying to execute a task function with a return value of a dataset. There doesn't seem to be a way to capture the dataset back in the Main(). I can only define a variable in the call function declaration - no way to define a dataset. If I don't define a return variable I receive the error "No current AmlParam".

Below is an example using the local processes. How do I make the results of ExampleTask (myDataset) available to the caller (Main)?

The return command defaults to variable. I changed the AML to be TYPE="dataset" and I no longer receive the AmlParam error, but it still doesn't make the dataset available to Main.


Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------
Automate 11 BPA Standard
Windows Server 2016
 07/30/2018 07:41 AM
User is offline View Users Profile Print this message

Author Icon
Justin Aucoin
HelpSystems

Posts: 360
Joined: 02/15/2016

Hi Patrick,

To return access a dataset populated in a function call, you first need to create a dataset under the Task Variables. To do this, first click on Task Variables in the Task Builder, then click on the green plus. Change the Type to dataset and provide the name you wish to use for the dataset. Leave it set to Public and click the green check box to save. You can then reference the dataset as normal after the function call.

-------------------------

Justin Aucoin | Support Analyst
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700 | F: +1.213.738.7665
 07/30/2018 07:56 AM
User is offline View Users Profile Print this message

Author Icon
PatrickMarshall
Student (5-19 posts)

Posts: 13
Joined: 06/14/2016

So, the configuration of the function to return a dataset doesn't actually work? It needs to be a shared dataset across the task?

Is this going to be fixed in a future version? It defeats the purpose of having a function if you can only use the same dataset name each time.

-------------------------
Automate 11 BPA Standard
Windows Server 2016
 07/30/2018 01:28 PM
User is offline View Users Profile Print this message

Author Icon
Justin Aucoin
HelpSystems

Posts: 360
Joined: 02/15/2016

Hi Patrick,

I will put in a feature request to have datasets and arrays added as a return option in the function calls. In the meanwhile, you can create a task dataset(s), which will allow the called functions to populate a dataset that is accessible in the Main function. I have attached a quick example of this. The 'Function dataset' task has one Task dataset, dsFiles, which is populated twice with files information from the Automate Program directory. The first function get's populates the dataset with the information for exe files and after it runs the task displays the total number of rows. The second function does the same, but with dll files.




-------------------------

Justin Aucoin | Support Analyst
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700 | F: +1.213.738.7665
 07/31/2018 05:49 AM
User is offline View Users Profile Print this message

Author Icon
PatrickMarshall
Student (5-19 posts)

Posts: 13
Joined: 06/14/2016

Hi Justin,

The feature is already there. The option when defining the function is to select the return type, and Dataset and Array are valid responses. See the attached screenshot.

So, does this functionality not work at all even though it is presented as an option? Is there a way to pass a dataset pointer as a parameter instead?

I need to execute a REST GET operation against different forms and then compare the results between the yielded datasets. ie:

dataset1 = getREST(query1,form1)
dataset2 = getREST(query2,form2)

Using a global dataset is not feasible for this process. I know I could return the JSON text then manipulate it in the calling code, but that would mean duplication of code that should be in the function.

Click for full image
Click for larger image



-------------------------
Automate 11 BPA Standard
Windows Server 2016
 07/31/2018 10:43 AM
User is offline View Users Profile Print this message

Author Icon
Hamid Noorbakhsh
HelpSystems

Posts: 454
Joined: 07/29/2008

Patrick,

Very quickly, Justin and I have discussed this. This is available in release version, BUT there is no way to create an empty Dataset unless it is a 'Task' one. One can return the Dataset and use it currently, but the AMTB variable panel is unaware of the switch with function datasets and will not update them. This is an issue that your question surfaced and I already addressed it for next build. To better understand my example, you can create a task with following code - you need to also create a function AmFunction1 that returns a Dataset as you have mentioned.

The task will run correctly, but you will not be able to inspect the dataset in AMTB until this is available in next release. BUT if you are only worried about running it and not inspecting the data in AMTB you are good to go!


Also you could create 2 Task Datasets and return the functions results into dataset1 and dataset2, if you need the empty one?

Good luck and hopefully this helps!?


Edit - Forgot to mention that the feature request Justin mentioned was for creating a function empty Dataset.


Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------
Thank you for choosing AutoMate

Hamid Noorbakhsh | Senior Software Engineer
AutoMate | A Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700

Edited: 07/31/2018 at 01:58 PM by Hamid Noorbakhsh
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 787 guests browsing this forum, which makes a total of 787 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2019 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog