Baseline Policies

DateAdd Policy

You can use the DateAdd policy as a sub policy to add a time interval to a time stamp value. The DateAdd policy is configured as an alternative for the date add functions in queries and R scripts.

The DateAdd policy uses the following inputs to perform the addition:
  • Time stamp to which you want to add the time interval.
  • Time interval that you want to add to the time stamp.
  • Unit of time in which the interval is defined.

How DateAdd Policy Works

The following image illustrates the DateAdd policy:

In this policy, the interval value, the unit of time in which the interval is defined, and the time stamp to which you want to add the time interval are passed as inputs from the calling policy, and they are represented by the Point Value nodes. The Case and Math node use the time interval value and its unit to calculate the number of seconds in the specified interval. The Add node then adds the number of seconds to the time stamp and the resultant date is passed back to the calling policy by the Return Value node.

DateDiff Policy

You can use the DateDiff policy as a sub policy to calculate the difference between dates in terms of the following units of time:
  • Years
  • Weeks
  • Days
  • Hours
  • Minutes

You can use the DateDiff policy as an alternative for the date difference functions in queries and R Scripts to calculate time difference between dates.

How DateDiff Policy Works

The following image illustrates the DateDiff policy:

In this policy, a Subtract node is used along with a Convert Type node to calculate the number of seconds between dates. The dates are passed as inputs from the calling policy, and they are represented by the Point Value nodes in this policy. The number of seconds between the dates is then converted by the Math nodes to years, weeks, days, hours, and minutes and passed back to the calling policy via the Return Value nodes. Depending on the unit of time in which the difference between the dates is required in the calling policy, you can map the desired output from the Sub Policy node to the appropriate node in the calling policy.

String Replace Sub-Policy

You can use the String Replace Sub-Policy to replace a string with a different string within a single text value, or, by using the sub policy in a loop, a collection of text values.

The String Replace Sub-Policy provides one output value or collection: Output String.

The following table describes the inputs used by the String Replace Sub-Policy.
Input ValueNotes
Input StringAny text value.
Search StringThe text value that you want to search for within the Input String. This input accepts Regular Expressions, allowing for more complex searches.
Replacement StringThe text value with which you want to replace instances of the Search String within the Input String.
Ignore Case?If true, the string replacement function ignores the case of characters in the input string when searching for matching strings to replace.

How String Replace Sub-Policy Works

The following image illustrates the String Replace Sub-Policy:

This policy uses the R Script Public\Meridium\Modules\Policy Manager\RScripts\StringReplace, which contains the following code:
outputText <- gsub(pattern, replacementText, inputText, ignore.case =
        as.logical(ignoreCase), perl = FALSE, fixed = FALSE, useBytes = FALSE)

Each time the sub-policy is executed, the R script is evaluated. It uses the base R gsub() function to replace all instances of the Search String (represented by pattern in the R Script) in the Input String (represented by inputText), with the Replacement String (represented by replacementText). If the value of Ignore Case? evaluates to True, the search and replace is not case sensitive.

For more advanced use cases, you can use a Regular Expression as the Search String. For example, if you wanted to replace any numeric value in the Input String with the word “number”, you would enter \d+ as the Search String and number as the Replacement String.

Concatenate Text Email Example

You can use the Concatenate Text Email Example policy to send an email message to all the users in a security group, which means that there is no requirement to modify the policy when users are added to or removed from the group.

This policy is intended as an example of how to use the associated R Script to concatenate a collection of text values, using an optional delimiter string. The R Script can be reused as-is in other policies that require similar functionality, or you can copy and modify the R Script and example policy to achieve your objective.

How Concatenate Text Email Example Works

The following image illustrates the Concatenate Text Email Example policy:

This policy uses the query Public\Meridium\Modules\Policy Manager\Queries\Email Addresses for a Security Group to retrieve the email addresses of all users in the security group with the ID specified in the Security Group ID Constant node.

The policy then uses the R Script Public\Meridium\Modules\PolicyManager\RScripts\ConcatenateText to concatenate the list of email addresses, adding the value specified in the Delimiter Constant node, a comma, between each email address.The R Script contains the following code:

concatenatedText <- paste(inputTextCollection, collapse = delimiter)

The Concatenated Text output from the R Script node is then used as the input to the To Address section of the Email Contact node.