Workflow and ServiceDesk Community

 View Only

Using a User Defined Type with the Script Component - Workflow 

May 21, 2015 05:55 PM

In this Article I will show you how to use a custom data type within the Script Component.

So you've created a "User Defined Type" from the Authoring section in a Int.png Workflow Integration Component

Create Generator (UDT).png

Property.png UserDefinedType
  Property (2).png TextProperty (Text)
  Property (2).png IntegerProperty (Number (integer))

1. Type Designer.png

 

2. Settings.png

Make sure to note the Namespace:

Generated.POC_Scripting_INT

 

C# Generators.png Generators
  C#.png UserDefinedType
    Property.png UserDefinedType

Generators Management (UDT) (2).png

 

Now create a Workflow.

Use an Data_Add.png Add Data Element and create a element of your new Data Type.

DataType UserDefinedType
Variable Name UserDefinedType

Add some values

Integer Property 1
Text Property Alex Hedley

Search for a Code (Script) Component.png Script Component. The Library may not have been added so should show in the Search.png Unloaded Libraries section.

You could also add "LogicBase.Components.Scripting.dll" in the Libraries tab of the Project section.

Join this to your previous component.

Double click on this to start up the Wizard.

Add your variable name and choose it's Type:

Scripted Component Wizard - 1. Input Parameters.png

Click on Edit Parameter Mappings.

Select the Parameter then choose the Data Source:

End Component Mapping.png

Click OK then Next.

Choose your "Result variable type" and "Result variable name":

Scripted Component Wizard - 2. Result Variable.png

Now to the Source Code.

You can choose which one you prefer. (C#, VB.NET, JScript)

Here is where you need to add your previous namespace.

Using namespaces (one per line):
System
Generated.Generated.POC_Scripting_INT

Now you can use your Type in the code:

return UserDefinedType[0].TextProperty;

Scripted Component Wizard - 3. Source Code.png

There is a handy test you can perform at the end to check it is working.

Scripted Component Wizard - 4. Test Page.png

Obviously you can do more complex things than just getting a single Property but this explains the initial set up.
 
 

Protirus.png

Statistics
0 Favorited
1 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Related Entries and Links

No Related Resource entered.