The Evaluate date function masking activity allows you to assign date values to the specified record column.
Table of contents |
---|
Usage |
Example |
Properties |
To use the Evaluate date function masking activity, it must be placed inside a table masking activity or a similar activity that iterates over data. Once placed, select the property you want to mask and enter a lambda expression that results in a date value you want to assign to that property. Expressions must be valid expressions resulting in DateTime instances.
While you can directly set a desired value, you can also use custom code to generate a value with a custom algorithm and data. Note that the Evaluate date function masking activity always evaluates the expression, i.e. the value (or the custom code that determines the value) is generated for each record. If you want to assign the same value to all records, use the Assign date masking activity instead. Additionally, the lambda expression gives you access to the record you are currently masking which allows you to use its values to determine the masked value.
In this example we want to mask the BirthDate column in the Customer table. We don't need realistic values from this column during testing, but we still need to mask sensitive data and want to use a valid value. However, we also want a bit of variety in our data, i.e. we don't want every record to be the same. We can do this is by assigning a date with a random year to every record in this table while using the original day and month values. First we place the Customer masking activity and put the Evaluate date function masking activity within it. Once placed, we select the BirthDate property that we want to mask with our chosen date.
In order to get some variety in the resulting date, we can write some custom code to create a random year and return a date with that year, but with the same day and month values as the original value. The code looks like this:
public static class Code
{
private static Random r = new Random();
public static DateTime GetRandomDate(DateTime originalDate)
{
return new DateTime(r.Next(1990, 2000), originalDate.Month, originalDate.Day);
}
}
The GetRandomDate(DateTime originalDate) method returns a new date which represents the original day and month in a random year between 1990 and 2000. We can then use this method in our lambda expression and pass the record (represented in the lambda expression as record) to our method. The lambda expression looks like this: record => Code.GetRandomDate(record.BirthDate)
. We leave other properties as they are.
Figure 1: Evaluating and assigning dates
Property group | Property name | Description | Example |
---|---|---|---|
Input properties | DataItemProperty | The property to mask. | Write x => x.BirthDate or choose property from the dropdown list |
Func | The function to use to get the replacement value. | record => Code.GetReplacementValue() |
|
Input: Filter | Filter | Expression used for filtering records - only filtered items will be masked. | x => x.BirthDate != null |
SkipDefaultValues | If true, default values will be omitted in masking (i.e. null values are not masked). | true or false |
|
Input: Repeating | RepeaterId | The ID of the repeater that will be used to detect repeating and save results when masking item key repeats. | DateRepeater |
RepeatingKey | Key to use for repeating detection. | Write x => CompositeKey.Create(x.BirthDate) or choose properties from the pop-up window |
|
Misc | DisplayName | Display name of the activity in the workflow. | Evaluate date function |
Result | Contains the masking definition object. It's a part of the masking infrastructure and should be ignored. | - |
BizDataX Documentation © Built by Ekobit. All rights reserved.
https://www.ekobit.com/ https://bizdatax.com/ https://bizdatax.com/support/