Error "BC30002: Type 'XXXXX is not defined" While Using Invoke Code Activity

Resolution for error obtained in the Invoke Code activity "BC30002: Type 'XXXXX' is not defined", even after the variable is defined in the code snippet .

Approach #1: Import the namespace of the defined variable datatype by following the below steps:

  1. Navigate to the "Import" tab in the UiPath Studio
  2. Search for the namespace of the variable datatype that is used in the Invoke Code activity and select them.
For example, if a variable of type JObject is used in the Invoke Code activity, ensure Newtonsoft.Json.Linq namespace is imported.

Approach #2: Define the variable explicitly in the Arguments section of the Invoke Code activity as shown in the screenshot below, instead of declaring in the code snippet.