November 10, 2020

Access WorkItem parameters from AppBundle

Inside your AppBundle's code, you do not have direct access to the values that were provided for the WorkItem parameters. 
However, the commandLine interpreter which resolves the special arguments inside $() - like $(args[hostDwg].path) - do.
So you can pass those values to your AppBundle through the commandLine - see picture above.  

You can also use this way to access the "value" provided for the "script" parameter of the Activity.

In the case of Inventor, you can rely on the map object that is passed to the RunWithArguments() entry function to read those arguments.
If such a thing is not available in the given product, you can always rely on .NET (or the underlying Windows API) to retrieve them - see Handle command line arguments.

People often send the data with information about how to modify the model in a json file - just like learnforge site tutorial is using a params.json file.
Instead of relying on the WorkItem to always send a file named "params.json" you could also pass the actual path of this file through the command line as shown above.

This way no matter if the file name is set by the "localName" parameter of the Activity or WorkItem, or it's based on the URL, you'll always have the correct path 😀 

Related Posts