Custom code token is the ability to execute a segment of custom code within a token. This functionality provide form developers with the full flexibility to execute and process form data to any specific needs. This functionality requires that the form developer have knowledge of the .NET C# language.
The format of a custom code token is as follows
[[CODE:custom code]]
where custom code is the segment of C# code.
the custom code must return a string in order for the token to properly evaluated. Line break can be included in the custom code.
Note: Opening and closing curly brackets { and } must be escaped with double curly brackets such as {{ and }}
Examples:
1. The simplest Hello World custom code is
[[CODE:
return "Hello World"
]]
when evaluated the above custom code token returns the string "Hello World"
2. Custom code with embedded standard tokens
[[CODE:
if ([FORM:field1] > [FORM:field2])
return "field1 is greater than field2";
else
return "field1 is not greater than field2";
]]
If field1 = 1 and field2 = 2 when evaluated the above custom code returns the string "field1 is not greater then field2"
Important Note:
Custom code tokens provide developers the flexibility to execute any segment of C# code. This of course has an associate security risk and therefore it is advisable that this particular function should only be activated if required. To turn on/off support for Custom Code tokens, refer to Advanced Portal Features.