Argument passing in python script

Hey, I’m working with the invoke python method in UIPaths I want to pass 3 arg to python fuction 2 string and one python obj how can I do that??

In UiPath, you can use the “Invoke Python Method” activity to execute Python code and pass arguments to the Python function. To pass three arguments, including two strings and one Python object, you can use the “InputArguments” property of the “Invoke Python Method” activity.

@devanshi

I’m using this but it is giving me an error


this
do you know how I can pass diff args like string, int and objects as well
@mpraveen1902

Hi

In your Python script, define a function that accepts three arguments, which could be two strings and one Python object.
For example:

def my_function(arg1, arg2, arg3):
# Your Python code here
print(arg1)
print(arg2)
print(arg3)

In UiPath

  • Add the Invoke Python Method activity to your workflow.
  • In the activity’s properties, set the CodeFilePath to the path of your Python script.
  • In the MethodName property, enter the name of the Python function (e.g., “my_function”).
  • In the InputParameters property, you can pass your arguments as an Object[] array. For example:

csharpCopy code

Object[] inputParameters = new Object[] { "Hello", "World", somePythonObject };

Here, "Hello" and "World" are the two string arguments, and somePythonObject is your Python object.

  1. In your Python code, you can access these arguments as you would in a regular Python function, like arg1, arg2, and arg3.

You can refer these threads for more ideas and example

Cheers @devanshi

you can go with this

@devanshi

I appreciate your support but cannot understand this as I’m uncomfortable with Csharp. can you provide other options if there are any?

It’s not a big change
U just need to include those arguments non ur python script and assign them value from arguments property in python activity

@devanshi

can you elaborate a little? I would really appreciate this as I’m new with UIpaths so it’s bit challenging for me

Would recommend to check this

@devanshi


I tried your solution but it is still giving error
@Palaniyappan

I have seen but it’s still not clear for me

Pass it like this in python activity
Not in studio variable panel
@devanshi


Like this? it’s still giving errors

e

Keep after = symbol as value

inputParameters Is the argument name
Object is the type of it
@devanshi

This is still giving errors What I do now?
@Palaniyappan