Skip to main content
Nintex Community Menu Bar
Solved

How to user Parameters field in Run Script command

  • February 28, 2024
  • 6 replies
  • 118 views
  • Translate

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. 

View original
Did this topic help you find an answer to your question?

6 replies

Forum|alt.badge.img+10
  • Scout
  • 129 replies
  • 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. 

Translate

Forum|alt.badge.img+2
  • Author
  • Rookie
  • 6 replies
  • 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. 

Translate

Forum|alt.badge.img+10
  • Scout
  • 129 replies
  • 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]

 

Translate

Forum|alt.badge.img+2
  • Author
  • Rookie
  • 6 replies
  • 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.

 

Translate

Forum|alt.badge.img+10
  • Scout
  • 129 replies
  • Answer
  • March 1, 2024

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

Translate

Forum|alt.badge.img+2
  • Author
  • Rookie
  • 6 replies
  • 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. 

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings