Creation rules

<< Inhaltsverzeichnis anzeigen >>

Navigation:  Start > Customize templates > Create templates > All template types > Inputs > Basic structure of an input method >

Creation rules

All input fields that can contain a constraints field can define a CreationRule within the constraints field, which automatically calculates the value of the field.

 

Creation rules are only valid if you do not define a default value.

 

Creation rules can be linked to one another as desired, e.g.  „<firstLetter>({givenname}).{sn}@[fqdn]“. Spaces are also relevant.

 

The creation rule is also executed when the field:

Is hidden ("IsHiddenFromRequester": true or  "IsHidden": true)

Is not editable ("IsEnabled": false)

 

 

Possibilities for creation rules

{sn}

This text is replaced by the current value of the input field for the LDAP attribute specified in curly braces (in this example, "sn").

This also works if the referenced input field is hidden and / or not editable.

If the referenced field contains a creation rule, it is executed first. The order of execution is calculated on the basis of such field dependencies. If the creation rules of a template form a cyclic field dependency (for example, if the creation rule for "sn" contains {cn} and that for "cn" {sn}), the template is rejected as invalid. The error is displayed in the health check.

 

 

[fqdn]

This text is replaced by the domain name defined in the template (FullQualifiedDomainName).

 

 

Hello 123

Strings are accepted one by one, in this case "Hello 123".

The following special characters must be escaped with a backslash (\): backslash, round brackets, braces, comma.

Note: In JSON format, the double quotes and the backslash must be escaped with a backslash. Backslashes in creation rules must therefore be doubled, e.g.

"\\(" for the round bracket

"\\\\" for a single backslash

A simple solution is provided by online tools that perform escaping for the JSON format e.g. http://www.infobyip.com/jsonencoderdecoder.php. So you only have to manually perform the escaping for the creation rules.

 

 

<firstLetter>(…)

Returns the first character of the argument.

Example

<firstLetter>(Hello) is replaced by "H".

 

 

<toUpperCase>(…)

Converts the argument to uppercase.

Example

<toUpperCase>(Hello) is replaced by "HELLO".

 

 

<toLowerCase>(…)

Converts the argument to lowercase.

Example

<toLowerCase>(Hello) is replaced by "hello".

 

 

<trim>(…)

Deletes spaces at the beginning and end of the argument.

Example

<trim>( Hello ) is replaced by "Hello".

 

 

<subst>(…)

Deletes blanks and hyphens from the argument, replacing letters with accents by letters or combinations of letters without accents.

Example

<subst>(Zoë Roßmäßler-Öker) is replaced by "ZoeRossmaesslerOeker".

 

 

<replace>(.,.,.)
<replaceOnce(.,.,.)>

Replaces characters.

Examples

<replace>(the dog and the fox,the,a) = "a dog and a fox"

<replaceOnce>(the dog and the fox,the,a) = "a dog and the fox"

<replace>(Norbert Van Eggert, ,) = "NorbertVanEggert"

<replace>(Norbert Van Eggert, ,.) = "Norbert.Van.Eggert"

 

 

<regExpr>('…',…)

Specifies the first match of the regular expression (within the single quotation marks), applied to the second argument (begins immediately after the comma, spaces after the comma are counted).

Example

<regExpr>('.{3}',Hello) Is replaced by "Hel".

 

All common regular expressions are supported. As a special feature, the grouping construct (? <This> ...) is also supported. The match on this group is returned.

Example

<regExpr>('.{3}(?<this>.*)',Hello) Is replaced by "lo".

 

There are online tools that can be used to test regular expressions, e.g. http://regex101.com.

All functions can be arbitrarily nested.

Example

<regExpr>('.{1}',<trim>(<toLowerCase>({sn})))

 

 

 

Complex example for an email address validation

"Name": "emailaddresses",

"Definition": {

  "Type": "TextArea",

  "Label": "Email addresses",

  "IsRequired": true,

  "IsEnabled": true,

  "Constraints": {

    "MaxLength": 500,

    "ValidationRule": "^((([a-z][a-z0-9]+:)?([A-Z][A-Z0-9]+:)?(\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*(\\r\\n)?\\n?)+)*)$",

    "ValidationInformation": "Does not match the email format!",

    "CreationRule" : "SMTP:<tolowerCase>({samaccountname})@<tolowerCase>([fqdn])\r\nsmtp:<tolowerCase>(<firstLetter>({givenname})).<tolowerCase>({sn})@<tolowerCase>([fqdn])"

  }

}