Skip to main content

Does anyone know how to use Parameters field in Run Script command? If I have, say, a python code as in the picture, how do I pass “testInputVariable” into the code to be used as variable a of function testFunction?

@Alisher SV Do you have a need to actually pass the variable as a parameter into the script, or can you just use the variable within the script, without any parameters?

def testFunction(a):
return a


b = testFunction($testInputVariable$)

print(b)

 

Disclaimer: I’ve never done anything with Python. 


Thank you @bsikes.

The way you showed is the way I do it now and it works.

Yet, I would like to learn how to use Parameters fields because it would allow me to keep the code and input variables separately. 


Do you know how you would pass parameters to a python script outside of Nintex, such as from a command prompt window?  It’s probably very similar. 

https://stackoverflow.com/questions/22846858/python-pass-arguments-to-a-script

 

That makes me think you’d need to include this to access, as example, the first parameter passed to the script:

import sys

firstParameter = sys.argvy0]

 


Yes, parameters are passed to python function as indicated in your response. 

I tried your recommendation and instead of input variable, it is returning the path to a temp file.

 


Maybe try sys.argv[1] instead?  I’m not entirely sure how Nintex RPA is executing the scripts. 


It did not work with sys.argvv1], but worked with sys.argvg2]. 

So, to access parameter 1,  sys.argv.2] needs to used, for parameter 2  sys.argvy3], … so on so forth.

Thanks a lot @bsikes, this answers my question. I wish Nintex website provided these details. 


Reply