Fast Formulas: Using Arrays in Fusion
Fast Formulas: Using Arrays in Fusion
Fast Formula provides several functions for managing arrays, such as COUNT to retrieve the count of elements, DELETE to remove specific elements or all, EXISTS to check if an index exists, FIRST and LAST to find the first and last indices, and NEXT and PRIOR to move between indices. These functions facilitate comprehensive array management by enabling manipulation of array data, handling of dynamic indexing, and efficient loop constructions within fast formulas .
The "Total Compensation Item" type in Fusion's Fast Formula supports arrays, allowing complex data processing within compensation-related calculations. By supporting arrays, this formula type can handle multiple values simultaneously such as different compensation components for assignments. This ability enhances the customization and depth of compensation calculations, as arrays can store and retrieve multiple data entries efficiently, leading to sophisticated and nuanced compensation management .
The CHANGE_CONTEXTS function within the Fast Formula loop is crucial for setting the operational context of the formula to the current assignment id. By associating HR_ASSIGNMENT_ID with CMP_IVR_ASSIGNMENT_ID[index], the function ensures that any operations, such as data retrieval and processing within the loop, are relevant to the current assignment data. This context-switching capability allows precise control over which assignment data the formula processes during each iteration, facilitating accurate and contextually-appropriate data manipulation .
Developers can determine the first index of an array by using the .FIRST method, which returns the first index of an array, taking a default value if the array is empty. This is done by employing syntax such as 'index = CMP_IVR_ASSIGNMENT_ID.FIRST(-1)'. Knowing the first index is crucial for effectively looping through arrays, particularly in cases where the array indexing may not start at 1, helping avoid errors and ensure robust data handling .
In Fusion Fast Formula, array variables are declared by specifying the type of value and index. For example, a variable array can be declared using syntax like 'DEFAULT FOR COMPENSATION_DATES is EMPTY_TEXT_NUMBER', indicating that it stores text values indexed by numbers. Defaulting these arrays involves setting an initial state or value which might be empty, as demonstrated by the use of 'EMPTY' in the declaration .
When utilizing Array DBIs in Fusion applications, it is essential to implement proper validation to ensure data integrity and avoid performance issues. Array DBIs, which store a range of data, may result in inefficiencies or slowdowns if not managed correctly. Ensuring that the array's contents are validated and optimized for retrieval can significantly impact performance. Using appropriate default values and ensuring relevant data indexing also play vital roles in maintaining efficient processing .
Arrays in Fusion Fast Formula significantly enhance the processing of input values by allowing the formula to handle multiple data points simultaneously. For instance, in Total Compensation Statements, an individual's assignments are processed at a person level. If an individual has multiple assignments, these are passed to the formula as an array, enabling processing across all assignments collectively. This not only optimizes data handling but also ensures comprehensive and efficient data processing in scenarios such as multi-assignment contexts .
A Fast Formula can loop through assignment arrays by first determining the starting index using the .FIRST method. For example, 'index = CMP_IVR_ASSIGNMENT_ID.FIRST(-1)' sets the initial index. The loop then proceeds by checking the existence of each index element using .EXISTS. Within the loop, context for each assignment is set, 'CHANGE_CONTEXTS(HR_ASSIGNMENT_ID = CMP_IVR_ASSIGNMENT_ID[index])', enabling the formula to process each assignment's data, such as salary changes. The subsequent salary change values are evaluated and stored in array variables, moving to the next element with .NEXT method, effectively iterating through the assignments .
The NEXT function in an array aids in iterating through indexes by returning the subsequent index of a given index. If there is no next element, it returns a specified default value, ensuring the loop can terminate gracefully at the end of an array. A typical default value used is '-1', as demonstrated in 'l_index = l_array.next(l_index, -1)'. This usage allows seamless iteration over arrays without out-of-bound errors when the array is exhausted .
Fusion Fast Formula supports various types of arrays based on combinations of value and index types. These include DATE_NUMBER (Date value and number index), DATE_TEXT (Date value and text index), NUMBER_NUMBER (Number value and number index), NUMBER_TEXT (Number value and text index), TEXT_NUMBER (Text value and number index), and TEXT_TEXT (Text value and text index). Each array type serves a specific purpose depending on the type of value it stores and how the array is indexed .