Issue with Invoke Code ("Map Variables" Pre-release)

Hi @Allan_Zimmermann

I’m just reporting that I’m having some issues with the new pre-release (map-variables) in invoke code activity.
It seems that all variables with data and type datatables are being “sent” as null. I have tried to use “breakpoint” and it is always null but the variable with string and integer works fine.
When I add an “if” to verify or validate if the datatable variable this error is displayed:

# Object reference not set to an instance of an object.

image

Can you help me on this? If you need more please let me know.

You have set datatable as out, so python will not be able to see the datatable
( if you are trying to send a data table FROM python, that has never been supported ( I’m 99% sure of that … when adding the mapping i did wonder why there was only added code for converting integer and boolean’s. You can validate that by simply removing all mappings, then the old code is used where all variables are mapped ))

Hi @Allan_Zimmermann
What I’m trying to do is send the datatable from python code to openrpa.
If you can check out this topic: https://discourse.openiap.io/t/how-to-save-json-api-respont-to-datatable-invoke-code/536?u=kowts, It was possible to make it work.

Hmm, so it HAS worked at some point ?
That’s strange, i don’t see anything in the code that can convert a python Dict to a data table :-/
If you disable all mappings does it work again ? ( note: I did not change or remove the original code, O just add’ed an IF statement, saying, if a mapping of variable was made, just map those instead of every variable )

If it work’s when you remove the mappings, i would love to get a small example showing it, then i can try and debug what is different between the old and new code for mapping variables .

From the example that I shared, it seems to work.

Yes, when I removed all the mapping it worked and I tried to reproduce a demo, hope this helps.
DataTable Tests.xaml (6.6 KB)

1 Like

@Allan_Zimmermann I was able to get the datatable by returning the data as a “json string” from python to openrpa and then convert the “json string” to datatable by assing a variable to this code:

JsonConvert.DeserializeObject(of DataTable)(dataJson)
1 Like

Glad you found a work around, I will look at your example and see if i can reproduce and fix it.

1 Like

it took me longer to get the requests module working in python, than fixing this.
I had made a stupid mistake

var obj = Newtonsoft.Json.JsonConvert.DeserializeObject(pyobj.ToString(), a.Value.ArgumentType);
Arguments[a.Key].Set(context, pyobj);

I was not setting the correct object to the variable value

var obj = Newtonsoft.Json.JsonConvert.DeserializeObject(pyobj.ToString(), a.Value.ArgumentType);
Arguments[a.Key].Set(context, obj);

Is fixed in this version

1 Like

Hi @Allan_Zimmermann,

There’s no such thing as a ‘stupid mistake.’ Every mistake we make provides an opportunity for growth, learning and gain more experiences.

Once again, thanks for the quick fix. :smiley:

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