Depends what you mean by using sys.argv. I can call this script from the command line with an arguement or call the run() method directly from UiPath with the text argument. This is the python code:
import sys
def run(text):
return " Hi " + text
if __name__ == "__main__":
run(sys.argv[1])
and this is the invoke python activity to call the script:
Does your python script start with the line import sys?
Can you run the python from the command line with a text argument? If it doesnât run from the command line either then you must be missing the sys module (which is part of a standard install)
Hi,
Can you please tell me how do i pass multiple arguments in the Input Parameters section.
my arguments are variables.(2 file paths and 1 integer value).
For UiPath the if part is actually not necessary it would run just the same without it. But running from the command line itâs used to call the function.
Hi,
Thank you for the reply, I was wondering if we could pass a variable in the Parameters section of Invoke method.
for ex: in your example, âBobâ be stored in a variable in uipath and that variable be called in the parameters section.
I however did try passing a variable, the dropdown variable box appeared but evrytime i run the Workflow it throws an error saying âError during Invoking the methodâ.
You definitely can use variables in the arguments collection. If it doesnât work for you then there must be some other error in your script or workflow.
def robot(a,b,c):
result = int(a)+int(b)+int(c)
print(result)
return(result)
if __name__ == "__main__":
robot(sys.argv[1],sys.argv[2],sys.argv[3])
And the robot print 124 as the result so it works as expected. Are you sure you are passing the input parameters as the type the python script accepts. For example are they type int32 or Generic, they need to be int32 for this to work.
when you load the python script in UiPath any functions (defined by the def statement) become available to call. You simply make your functions or methods in python and call them whatever you want and then call them from UiPath.
A python script could have 5 functions called def func1, def func2, def func3 and then you could call âfunc1â, âfunc2â or âfunc3â from UipPath.
Hello,
Thank you for your continuous guidance, Iâm now understanding where the problem was at.
I did try the exact same code but i took the inputs from the use using the âinput Dialogâ n then passed those to the âinvoke Methodâ activity. it throws an error i havenât seen before.