Generates integer numbers in a sequence (for example, 1,2,3,4, ...). It is possible to set the starting integer, the increment value, and other options by means of parameters.
The exact order in which functions are called by the generated mapping code is undefined. MapForce may need to cache calculated results for reuse, or evaluate expressions in any order. Also, unlike other functions, the auto-number function returns a different result when called multiple times with the same input parameters. Therefore, it is strongly recommended to use the auto-number function cautiously. In some cases, it is possible to achieve the same result by using the position function instead.
Built-in, C++, C#, Java, XQuery, XSLT 1.0, XSLT 2.0, XSLT 3.0.
Optional parameter. If a mapping design contains multiple auto-number functions, they will generate sequences with duplicate (overlapping) numbers. To make all auto-number functions aware of each other, and thus generate sequences that do not overlap, connect a common string (for example, a constant) to the global-id input of each auto-number function.
Optional parameter. Specifies the integer with which the generated sequence begins. The default value is 1.
Optional parameter. Specifies the increment value. The default value is 1.
Optional parameter. Resets the counter to start-with, when the content of the connected item changes.
The following mapping is a variation of the ParentContext.mfd mapping discussed in the Example: Changing the Parent Context.
The goal of the mapping illustrated below is to generate multiple XML files, one for each department in the source XML file. There are some departments with the same name (that's because they belong to different parent offices). For this reason, each generated file name must begin with a sequential number, for example 1-Administration.xml, 2-Marketing.xml, and so on.
To achieve the mapping goal, the auto-number function was used. The result of this function is concatenated with a dash character, followed by the department name, followed by the ".xml" string in order to create the unique name of the generated file. Importantly, the third parameter of the concat function (the department name) has a priority context applied. This has the effect that the auto-number function is called in the context of each department, and produces the required sequential values. If priority context were not used, the auto-number function would keep generating number 1 (in the absence of any context), and duplicate file names would be generated as a consequence.