Can we declare global variables for invoke code in Uipath

Hi,
My requirement is I am writing some c# code to fetch values from mongoDb and then passing them as arguments to use those variables in other sequence.

I want to declare those variables as global variables so that the the vales fetch from c# code can be used in any sequence.

Is there any way of doing it. I tried it by using global variables but it is giving me error viz “empty path name is not legal”
Attaching logs for reference:

Error: System.Exception: Empty path name is not legal.
at System.IO.Strategies.FileStreamHelpers.ValidateArguments(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at Roslyn.Utilities.StandardFileSystem.OpenFile(String filePath, FileMode mode, FileAccess access, FileShare share)
at Roslyn.Utilities.CommonCompilerFileSystemExtensions.OpenFileWithNormalizedException(ICommonCompilerFileSystem fileSystem, String filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
at UiPath.Studio.Plugin.Workflow.GlobalVariables.GlobalVariablesCompiler.<>c__DisplayClass13_0.b__2(String location)
at UiPath.Shared.Extensions.CollectionExtensions.ForEach[TItem](IEnumerable1 collection, Action1 action)
at UiPath.Studio.Plugin.Workflow.GlobalVariables.GlobalVariablesCompiler.GetMetadataReferences(IEnumerable1 dependencies) at UiPath.Studio.Plugin.Workflow.GlobalVariables.VisualBasicGlobalVariablesCompiler.CreateCompilation(String assemblyName, IEnumerable1 syntaxTrees, IEnumerable1 dependencies) at UiPath.Studio.Plugin.Workflow.GlobalVariables.GlobalVariablesCompiler.Run(IEnumerable1 globalVariables, String outputDirectory, String assemblyName, String& assemblyPath)
at UiPath.Studio.Workflow.GlobalVariables.GlobalVariablesAssemblyManager.GenerateAssembly(ExpressionLanguage language, String projectDirectory, IEnumerable1 variables, String& assemblyPath) at UiPath.Studio.Workflow.GlobalVariables.GlobalVariablesAssemblyManager.GenerateCorrespondingAssembly(ExpressionLanguage language, String projectDirectory, IEnumerable1 variables)
at UiPath.Studio.Plugin.Workflow.GlobalVariables.GlobalVariablesInstallerProjectService.InstallInternal(String projectDirectory, ExpressionLanguage expressionLanguage, String assemblyPath, IEnumerable1 variables) at UiPath.Studio.Plugin.Workflow.GlobalVariables.GlobalVariablesInstallerProjectService.Install(String projectDirectory, ExpressionLanguage expressionLanguage, IEnumerable1 variables)
at UiPath.Studio.Plugin.Workflow.GlobalVariables.GlobalVariablesProjectEndpoint.OnGlobalVariablesChanged(IEnumerable1 variables) at UiPath.Studio.Plugin.Workflow.GlobalVariables.GlobalVariablesProjectEndpoint.StoreVariables(IEnumerable1 variables)
at UiPath.Studio.Plugin.Workflow.Business.DataManager.Services.GlobalVariablesDesignerService.StoreGlobalVariablesWithValidDefaultValuesOnly()
at UiPath.Studio.Plugin.Workflow.Business.DataManager.Services.GlobalVariablesDesignerService.GlobalDesigner_ModelChanged(Object sender, EventArgs e)
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler), HResult -2147024809

1 Like

Hi @Riya_Bansal

Assigning a global variable to arguments in invoke code is not working?

If so you can try assigning to local
Variable and use assign activity next to assign that to global variable

Cheers

1 Like

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