Coding Snippets

Output Workflow/Activity Attributes using Lava

This is a quick way to output a formatted list of all the attributes of a workflow or an activity (e.g. to quickly output the answers from a form to a memo field on an entity or in an email or in a PDF)

<dl>
    {%- for attribute in Workflow.AttributeValues -%}
        <dt>{{ attribute.AttributeAbbreviatedName }}</dt>
        <dd>{{ attribute.ValueFormatted }}</dd>
    {%- endfor -%}
</dl>

<dl>
    {%- for attribute in Activity.AttributeValues -%}
        <dt>{{ attribute.AttributeAbbreviatedName }}</dt>
        <dd>{{ attribute.ValueFormatted }}</dd>
    {%- endfor -%}
</dl>

To limit the output to a subset of attributes - add an underscore (_) to the front of the AttributeKey...

<dl>
    {%- for attribute in Workflow.AttributeValues -%}
        {%- assign keyPrefix = attribute.AttributeKey | Slice:0,1 -%}
        {%- if namePrefix == '_' -%}
            <dt>{{ attribute.AttributeAbbreviatedName }}</dt>
            <dd>{{ attribute.ValueFormatted }}</dd>
        {%- endif -%}
    {%- endfor -%}
</dl>

Finding & Replacing Smart Quotes

{%- assign stringWithSmartQuotes = ..... -%}
{%- capture regExSmartSingle -%}[\u2018\u2019\u201a\u201b\u2032\u2035]{%- endcapture -%}
{%- capture regExSmartDouble -%}[\u201c\u201d\u201e\u201f\u2033\u2034\u2036\u2037]{%- endcapture -%}
{%- assign cleanedString = stringWithSmartQuotes | RegExReplace: regExSmartSingle,"'" | RegExReplace: regExSmartDouble,'"' %}

Delimited Lists with Sets and Items

These are my standard delimiters when I'm creating a list in a workflow for loop processing. The set delimiter separates what gets passes as input into each loop. The item delimiter is used to pass multiple 'things' in that input (e.g. a person GUID, an action, a message, etc)

{%- assign setDelimiter = '^|^' -%}
{%- assign itemDelimiter = '_^_' -%}

SQL - Joining to Person via Person Alias

SELECT  stuff
FROM    [SomeTable] st
INNER JOIN  [PersonAlias] pa
    ON  pa.[Id] = st.[PersonAliasId]
INNER JOIN  [Person] p
    ON  p.[Id] = pa.[PersonId]

SQL - Joining to Attribute Value

This shows an example of joining GroupMember table to the Attribute Value table to get a couple group member attributes - 1 required and 1 optional. Replace the 9999's for Ids with the actual Ids of your attributes.

DECLARE @GroupId INT
    , @RequiredAttrId INT
    , @OptionalAttrId INT;

SET @GroupId = 9999;
SET @RequiredAttrId = 9999;
SET @OptionalAttrId = 9999;

SELECT  stuff
FROM    [GroupMember] gm
INNER JOIN  [AttributeValue] requiredAV
    ON  requiredAV.[AttributeId] = @RequiredAttrId
    AND requiredAV.[EntityId] = gm.[Id]
    AND requiredAV.[Value] = 'Some Value'
LEFT JOIN  [AttributeValue] optionalAV
    ON  optionalAV.[AttributeId] = @OptionalAttrId
    AND optionalAV.[EntityId] = gm.[Id]
WHERE   gm.[GroupId] = @GroupId

SQL - Projects Plugin - Watching

SELECT  *
FROM    [_com_blueboxmoon_ProjectManagement_Watching]
WHERE   [PersonAliasId] IN (
    SELECT  pa.Id
    FROM    [PersonAlias] pa
    WHERE   pa.[PersonId] = < enter person id here >
)

Crossing Brand Colors variables in CSS

 :root {
        // primary brand colors
        --primary-color-crossing-blue: #425964;
        --primary-color-ice-blue: #bfd9da;
        --primary-color-dark-plum: #5f4750;
        --primary-color-light-forest: #919c67;
        --primary-color-quincy: #754230;
        --primary-color-burnt-orange: #aa6327;
        --primary-color-corduroy: #61736e;
        --primary-color-dark-spruce: #34474e;
        --primary-color-forest-green: #454823;
        // secondary brand colors
        --secondary-color-bright-teal: #357676;
        --secondary-color-light-yellow: #f4e4c6;
        --secondary-color-light-green: #96a891;
        --secondary-color-lifeblood: #a1302b;
        --secondary-color-golden-yellow: #e9c561;
        --secondary-color-nevada: #5e727e;
        --secondary-color-dust: #ae8042;
        --secondary-color-dark-brown: #56402f;
        --secondary-color-mule-brown: #ab997f;
        // neutral colors
        --neutral-color-armadillo: #3c3a36;
        --neutral-color-stone-path: #605d58;
        --neutral-color-overcast: #848079;
        --neutral-color-ash: #a8a49b;
        --neutral-color-bison-hide: #cbc4b8;
        --neutral-color-white: #ffffff;
    }

Comments are anonymous (unless you happen to have a Crossing account) - so please include your Name (and your email if you would like a response)