Code Source File (aka project-scoped type) not available when creating a global variable

Hi,

I’m playing around with the new code source files in UiPath Studio. I’ve created a new class called ProcessConfiguration and I want to create a global variable of that type. Unfortunately, when creating a new global variable the namespace is there, but it’s empty.

I can create a variable of that custom type (ProcessConfiguration) in any of the sequences, and it works fine. It’s only in the Global Variables section that this seems to be blocked.

Some screenshots for reference:
image

When creating a variable in any of the sequences
image

When creating a global variable
image

The same section of XXXX.REFramework.Hybrid.Core is expandable when creating a variable in a sequence but locked for the global variables

I tried:

  • closing and reopening the project
  • closing and reopening the UiPath Studio
  • restarting the whole PC just in case
  • manually altering the globalVariables.json

Is there any way to get UiPath Studio to recognise and display these classes?

Thanks,
Filip

edit1:
added the info about manual overwriting

@Filip_C

By definition of coded source file…I dont think global declaration is possible…as coded source files are valid at the individual xaml levels and not at the global level…

https://docs.uipath.com/studio/standalone/2023.10/user-guide/code-source-file

Cheers

@Anil_G

Thanks for the response :slight_smile:

I’m not sure I can agree with that “not by the definition” part though.
In the docs (your link) there’s a line that says “they [the coded source files] function within the context of a project” + “consistent structure throughout the project”.
Global variables are withing the context of the project too and therefore, by the definition, it should be possible.

On top of that:

  1. the type picker in the global variables section displays the assembly, so it knows it’s there. It just doesnt display the types that are within.

  2. global variables are actually capable of handling the custom types if you disguise them as Object. I’ve tried setting up a generic global variable
    image

then assigning a value to it (of my custom type)
image

image
image

and then, within the child sequence, printing it (with a type cast)
image

and the result is correct
image

So yes, it doesnt seem to be supported at the moment but, both by the definition and by the current behaviour it seems that it should be.
I’m currious to hear from the UiPath team if there’s a workaround for that or at least what’s the rationale behind that constraint.

Thanks anyway!
Filip

1 Like

@Filip_C

I believe as of now custom types are not getting reflected as they are not initialized also in the global context

source file are to be called in another flows and cannot be used directly

But yes lets hear

cheers

@Filip_C the code source namespace seems to function correctly after this project settings update. However, the potential trade-offs are not yet clear to me.

image

I am also higly interested in this topic, and did not find any solution yet, how to use custom classes as type for Global Variables