Lava Additions

Version 1.1.0

Last Updated Mar 2, 2018

Table Of Contents


Naming Conventions

In order to prevent naming collisions in the future, all Lava filters provided by this plug-in are prefixed with BBM_ to ensure uniqueness. Below you can find all the filters that are made available once this plug-in has been installed.

Array Filters

BBM_AddToArray

Add a new item to an existing array, also will create a new array if null or '' is used as the source array. While the examples use simple strings, you can add anything to an array - even entity objects such as a Group or Person.

BBM_Distinct

Takes an array as input and returns the distinct (unique) elements of the array.

BBM_GroupBy

Takes a collection of items and groups them by the specified property tree value. The returned data is a dictionary. Each distinct property tree value is represented as a key in the dictionary with all associated original objects as values of that key. As such, when iterating through the result you need to use the PropertyToKeyValue filter to get the key and the array of values.

BBM_OrderBy

Orders a collection of elements by the specified property tree and returns a new collection in that order.

You can sort by multiple keys, for example you can sort by LastName and then by FirstName at once. Each key to sort by is separated by a comma (,) character. Each sorted property can change the default order from ascending (default) to descending by appending a space and desc to the property name.

For example, if you specify the order by property of FirstName desc then the collection will be sorted by FirstName and the results will be returned in descending order.

BBM_RemoveFromArray

Take a collection of objects and return a new collection which does not contain the specified value.

BBM_Sum

Does a mathmatical summation of all numeric values in a collection and outputs the result.

Dictionary Filters

BBM_AddToDictionary

Takes an existing (or empty) dictionary and returns a new dictionary with the added key and value. Can pass null or '' to initialize a new dictionary.

BBM_AllKeysFromDictionary

Retrieves all keys that exist in the dictionary object and returns them in an array.

BBM_RemoveFromDictionary

Removes the specified key from a dictionary of keys and values.

Miscellaneous

BBM_AddHttpHeader

Adds a header to the HTTP Response of the current web request.

BBM_Call

Calls a function that was previously defined with the bbm_function command. The function to be called is the first parameter and any extra parameters are passed on to the function itself.

Function calls can be recursive, so you can call a single method from within itself. This can be useful when you want to build a list-item tree of groups.

Any lava variables you set inside a function will only exist in that function, they do not leak back to the scope of the calling Lava code.

BBM_ComputeHash

Computes the hash of the given string. Hashes are useful in verifying data hasn't been altered or for identifying data in a unique way without the possibility of determining the original data. Supported hashing methods are: SHA1, SHA256, SHA384, SHA512 and MD5. If the hashing method is not specified then it is assumed to be SHA1.

BBM_FromBase64

Decodes the base 64 encoded string and returns the resulting data. If the true parameter is passed then the data is returned as a human readable string. If not specified or false is specified then a byte array of the raw data is returned. Base 64 encoded is sometimes returned from API calls and usually must be decoded before it can be used.

BBM_PageRoute

Converts a page identifier into a URL string. The identifier can either be the page Id number, the Guid value or a full page route (as in the example) which contains "<PageGuid>,<RouteGuid>". You can optionally pass in a string of parameters to use when generating the URL. The parameters should be separated by ^. Each parameter should consist of a key and value separated by an =. You may also pass in a dictionary object that contains the parameters.

BBM_RunLava

Executes Lava that is inside a string. Very useful when taking Lava from an Attribute Value and wanting to process it to display it to the user. The Lava executes in the same security context as the existing Lava. So if you have Entity Commands enabled in your parent Lava then the child Lava you execute will also be able to run Entity Commands.

BBM_ToBase64

Converts the provided string into a base 64 encoded string. Input can also be a byte array instead of a string. Often times, data cannot be transmitted or stored in it's existing form because of limitations of the transmit medium. For example, when you attach a JPG image to an e-mail the image cannot be stored as JPG data. This is because the transmission of e-mail messages is limited to printable characters. In these cases, the data is encoded in what is known as base 64 and stored for transmission.

Text Filters

BBM_RegExMatches

Performs a regular expression search of the given input string. The first parameter is the regular expression to use when searching the input string. The optional second parameter specifies any flags to use during the regular expression search. Returns a collection of matches. If two matches for the expression are found then a collection of 2 matches will be returned.

Available flags:

  • i = Do comparison in a case-insensitive manner.
  • m = Multiline mode. ^ and $ will match the beginning and end of lines instead of the beginning and end of the entire input.

Each match object contains the following keys:

  • Index = The starting position of this match in the input string.
  • Length = The length of this match.
  • Value = The full string value that matched from the input string.
  • Groups = Collection of capture groups. A capture group is text surrounded by (...). These capture groups can be used as back references during a replace operation, or simply to extract a specific part of the string after a successful match. The first group will always be the entire matched string. So the first capture group that you specificy will be at index 1. Each group contains the following keys:
    • Index = The starting position of this match in the input string.
    • Length = The length of this match.
    • Value = The full string value that matched from the input string.

See https://regex101.com/ for help with constructing your regular expressions.

BBM_RegExReplace

Replaces a portion of the string passed as the input to the filter with regular expression matching. The first parameter is the regular expression to match against. The second parameter is the replacement string value. An optional third parameter contains any regular expression flags to use. Back-references can be used, as in the second example, but are slightly different than normal regular expression syntax. Normally you would use \1 to indicate the first capture group. .NET uses $1 to indicate the same.

Available flags:

  • i = Do comparison in a case-insensitive manner.
  • m = Multiline mode. ^ and $ will match the beginning and end of lines instead of the beginning and end of the entire input.

See https://regex101.com/ for help with constructing your regular expressions.

Commands

bbm_function

Defines a function that can be called later in the Lava code. The first parameter is the name of the function to define. Further parameters define the names of variables that will be provided to the function body. The data passed to the filter is made available as the Input variable.