Failed to assign a value to a variable using Python execution code

Two variables of the Object array type are defined here.I use Python to assign a value to the variable first in invoke Code. For example: first = [{‘invoiceNum’: ‘KE2301137’, ‘po_no’: ‘524428’}].
Then use another invoke code to assign a value to the second variable in Python.
The second variable is output and an error is reported.
I’d appreciate it if I could see why.

What is the error , and do you have to use python, vb.net is also available


Does this help

Thank you very much for your reply. I know it’s okay to assign data to variables directly. But what I want is a variable to assign a value to a variable. Can this be achieved?

I think I understand what you are looking for https://youtu.be/RbZg7NADa5U
marse337/PdfToCSV-RPA: This is an RPA that converts PDFs into CSVs then fills out a form (github.com)
I have created a workflow that reads a PDF then converts it into a CSV then reads the values from the CSV

image
Have you already tried the String object

Yes, I tried the String Object too, but the same error was reported. I see that you use String Objects in your workflow, but you use VB to assign values, I want to use Python.

I want to assign values to complex types, such as Object Array or String Array, and I find that other languages can be used to assign values to one variable to another, except Python.
It’s my workflow:
python code.json (8.3 KB)


Can I ask you, What are you doing to the variable “second” ? can variable second be just a string

In my real business, the variable “second” is in a loop condition. Different values are assigned to variable “second” according to different loop conditions. In addition, I only want the Object array type, not the String type.

@Allan_Zimmermann Can you help me see what’s the reason

The problem with Object or Object[] is it’s “untyped”.
Say, we declared some memory for the array, and you added something to it and then later referenced it, and you already knew the type. No problem.
But that is not what is happening here.
When you declare Object[] in the workflow, and you hit invoke code, it feeds the raw objects to the python interpreter and try to create a python variable with the values, this normally are ok handling Object type.
But when code execution stops, openrpa needs to parse the python variable and put the values back to the workflow. OpenRPA uses the type declared for the variable, in this case Object and that will either fail, or result in “empty” objects.

You need to set a type. A type that is supported in both openrpa and python ( and that invoke code can “cast” back to openrpa )
Current release only support basic types like string, int, bool ( or array of absic type, like string, int bool etc )
Current pre-release also support data tables

If you need untyped data to be sent back and forth, use string and parse the data as json both in python and openrpa.

Okay, thank you very much for your reply.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.