Skip to main content
Nintex Community Menu Bar
Solved

How to user Parameters field in Run Script command

  • February 28, 2024
  • 6 replies
  • 170 views

Forum|alt.badge.img+2

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?

Best answer by bsikes

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

6 replies

Forum|alt.badge.img+11
  • Contributor
  • February 29, 2024

@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. 


Forum|alt.badge.img+2
  • Author
  • Rookie
  • February 29, 2024

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. 


Forum|alt.badge.img+11
  • Contributor
  • February 29, 2024

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.argv[0]

 


Forum|alt.badge.img+2
  • Author
  • Rookie
  • March 1, 2024

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.

 


Forum|alt.badge.img+11
  • Contributor
  • Answer
  • March 1, 2024

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


Forum|alt.badge.img+2
  • Author
  • Rookie
  • March 1, 2024

It did not work with sys.argv[1], but worked with sys.argv[2]. 

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

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