Error when assign Variable using Invoke Code in StudioWeb Apps

I have to assign multiple Apps variables in a StudioWeb workflow, as there is no “Multiple Assign” activity yet i want to use “Invoke code” to simply do it in 1 activity.

The code is :

AppVariable.erp_orderDate = jsonObject.orderDate
AppVariable.erp_customerOrder= jsonObject.erp_customerOrder
etc ...

But i am facing this error, on execution (while using the app on running):

2025-09-08 10:51:07.860 CEST:	Error: System.ArgumentException: No compiled code to run
error BC30451: 'jsonObject' is not declared. It may be inaccessible due to its protection level. At line 0

   at UiPath.Activities.System.Utilities.InvokeCode.RoslynCompilerRunner.Compile(String code, Int32 errLineOffset, Boolean generateInMemory)
   at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner..ctor(String code, String className, String methodName, Int32 errLineOffset, Boolean generateInMemory)
   at UiPath.Activities.System.Utilities.InvokeCode.RoslynCompilerRunner..ctor(String code, String className, String methodName, Int32 errLineOffset, Boolean generateInMemory)
   at UiPath.Activities.System.Utilities.InvokeCode.VBCompilerRunner..ctor(String code, String className, String methodName, Int32 errLineOffset, Boolean generateInMemory)
   at UiPath.Activities.System.Utilities.InvokeCode.VBCodeInvoker.GetCompilerRunner(String code, String className, String methodName, Int32 errLineOffset, Boolean inMemory)
   at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.GetCompilerRunner(String userCode, List`1 args, String imps, Boolean inMemory, Boolean allowCaching)
   at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List`1 inArgs, IEnumerable`1 imps, Object[] args)
   at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


JsonObject is declared on the panel (Can’t spread the panel sry)

It works when i’m using the “Assign variable” so i’m not stuck, just want to ask, maybe i am missing something.

Try using expression editor to set value

Where is the expression editor on “Invoke code” in StudioWeb please ?

@simon.l,

Try using this way.

AppVariable.erp_customerOrder= AppVariable.jsonObject.erp_customerOrder

It’s not an AppVariable, it’s a workflow variable.

@simon.l

Any variables used inside invoke code needs to be sent into those activities via the arguments collection

So create an argument of type jobject and link your jaonobject to that argument and use the argument in your incoke code

Cheers