Using the last digits of the year in the records classification scheme (function)

When working with the records classification scheme, you may need to specify the last two digits of the year, for example, when generating a registration number (B1-CKP-17-0001, where 17 is the year). 

For this, you need to create a function for cutting off digits in the year. You can use a script in an Object or a Document. 
Let's take a look at an example: assume you need to specify the last digit of the year in the registration number (the current year is 2017; 7 must be inserted to the registration number). A script for cutting off year digits will look like this: 
public class CustomFunctionsContainer : ITemplateGeneratorFunctionsContainer
{ public static FormatedValue LastChar(FunctionEvaluationContext context)
   var s =context.Parameters != null && 
   context.Parameters.Count > 0 && 
   context.Parameters[0] != null && 
   context.Parameters[0].Value != null? context.Parameters[0].Value.ToString() : null; //check for being nullŒ
   return !string.IsNullOrEmpty(s) ? new FormatedValue(s[s.Length - 1]) : null; //cut off digits
For the script to work correctly, add the following namespaces:
using EleWise.TemplateGenerator;
using EleWise.TemplateGenerator.Functions;
using EleWise.ELMA.Templates;
In the process, create an object and insert the code on the Script tab (or insert it on the Script tab of a document type, to avoid creating an unnecessary object). Then publish the object and restart the server. 
After that, cancel publication of the classification scheme and use the code {LastChar({$RegistrationCard.AccountingYear.Year})} in the template. Publish the classification scheme. 


You can change the number of displayed digits by specifying in the last line of the script the required number. E.g. if you specify (s.Substring(s.Length - 2)), two last digits will be displayed, and if you specify (s.Substring(s.Length - 3)), the last three digits will be displayed. After performing the actions described above, the code {LastChar({$RegistrationCard.AccountingYear.Year})} can be used in any part of the template, where you need to specify the year of the classification scheme. 

For example, when creating a category in the Number Template field