.NET Script activity

Use the .NET Script activities to write .NET scripts. The TotalAgility Designer allows you to create two types of .NET Script activities: VB.NET and C#.

For a script to work in your process, assign process variables as input and output to the Script activity. See Set the variable as input and output.

  • To retrieve (get) the value of a process variable for use within a script, add the variable as an input variable.

  • To change (set) the value of a process variable within a script, add the variable as an output variable.

Important When configuring the script, you can manually enter the variables, such as ("[Firstname]") or drag and drop the variables into the script. When you drag and drop the variable, the variable appears as [Firstname]. Dragging the variable is only a shortcut to inserting the variable ID without the need of manually typing it. For the script to be valid, you must insert the quotes around it. Example: "[Firstname]." See Configure a .NET Script activity.

TotalAgility can validate and run a script without requiring the script developer to build and deploy .NET assemblies. The .NET compliance of TotalAgility reduces development time and increases the ease of deployment.

The following is an example of a VB .NET script:

Imports System Imports Agility.Server.Scripting.ScriptAssembly
Namespace MyNamespace
	Public Class Class1
		<StartMethodAttribute()> Public Sub Method1(ByVal sp As ScriptParameters)
			'			
			' TODO: Add start method code here
			'
			Dim FirstName
			Dim LastName
			FirstName = sp.InputVariables("FirstName")
			LastName = sp.InputVariables("LastName")
			sp.OutputVariables("Fullname") = FirstName + LastName
		End Sub
	End Class
End Namespace
 

In this sample VB .NET script, FirstName and LastName are input variables. The value of these variables is used to construct the value of the FullName variable, which is an output variable.

Note The script only works if FirstName and LastName are set as input variables, and FullName is set as an output variable.

The following is an example of a C# script:

using System; 
using Agility.Server.Scripting.ScriptAssembly;
 namespace MyNamespace
{
     public class Class1
 {
  public Class1() 
  {
  }
   [StartMethodAttribute()] 
  public void Method1(ScriptParameters sp) 
  {
	string firstName = sp.InputVariables["firstname"].ToString();
	string surname = sp.InputVariables["surname"].ToString();
	sp.OutputVariables["fullname"] = firstName + " " + surname ;
   }
 }
}