IdentityNow Transforms - Static

IdentityNow Transforms - Static

Overview

A static transform may be used to return a fixed string value or, more commonly, to evaluate Velocity Template Language. This latter implementation can come in handy when using if/then/else logic or iterating through a for loop. The static transform can also take as inputs into the value attribute other dynamically-provided variables, as demonstrated in the examples below.

Other Considerations

  • When using static transforms within the create profile for a source, the value can be entered directly in the input field if the user selects Static as the attribute type.

  • Because IdentityNow supports the ability to order attributes in a create profile, you can use the Velocity template of an attribute higher in the list to generate at static value for an attribute that is lower in the list. For example, if you want to generate an email address based on a display name, you'll need to:

    • Move the "displayName" attribute higher in the list so that it is created before the email address.
    • In the "mail" attribute, select Static for the attribute type. In the Static Value field, enter $displayName@yourdomain.com.

 

Transform Structure

In addition to the standard type and name attributes that are required for all transforms, a static transform also requires a value attribute to be specified:

Example

{
  "attributes": {
    "value": "Employee"
  },
  "type": "static",
  "name": "Test Static Transform"
}

Attributes

  • Required Attributes

    • type - This must always be set to static
    • name - This is a required attribute for all transforms, and represents the name of the transform as it will appear in the UI's dropdowns
    • value - This must evaluate to a JSON string, either through a fixed value or through conditional logic using Velocity Template Language
  • Optional Attributes

    • The static transform may implement variables within the value expression. These variables can be defined as optional attributes within the transform, and can themselves be the result of other transforms.
    • requiresPeriodicRefresh - A true or false value that indicates whether the transform logic should be re-evaluated every evening as part of the identity refresh process.

 

Examples

Example 1

{
  "attributes": {
    "workerType": {
      "attributes": {
        "sourceName": "HR Source",
        "attributeName": "empType"
      },
      "type": "accountAttribute"
    },
    "value": "$workerType"
  },
  "type": "static",
  "name": "Test Static Transform"
}

This transform uses a dynamic variable called workerType, which is set to the value of the HR record's empType value for the user. The static transform then returns that value through the use of Velocity variable notation (i.e., $<variableName>).

Example 2

{
  "attributes": {
    "workerType": {
      "attributes": {
        "sourceName": "HR Source",
        "attributeName": "empType"
      },
      "type": "accountAttribute"
    },
    "value": "#if($workerType=='Employee')Full-Time#{else}Contingent#end"
  },
  "type": "static",
  "name": "Test Static Transform"
}

The above transform extends the previous example to show that if/else logic can be used to return data based on contingent logic.

 

References

Tags (1)
Comments

Hi,

If the input specified for the attribute is null, then we see that IdentityNow fails to render the static expression. It keeps throwing error "Error rendering template:".

For instance in example 2, if empType is null, then the transform fails with the above said error.

Thanks,

VK.

Hey @venkateshkan you are absolutely right. What I have done to get around this and to ensure that there are no errors is utilizing the firstValid transform with this. See my example below:

 

{
    "attributes": {
        "workerType": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "sourceName": "HR Source",
                            "attributeName": "empType"
                        },
                        "type": "accountAttribute"
                    },
                    "null"
                ]
            },
            "type": "firstValid"
        },
        "value": "#if($workerType==\"Employee\")Full-Time#{else}Contingent#end"
    },
    "type": "static",
    "name": "Test_Static_Transform_with_firstValid"
}

 

As you can see with this method, if the accountAttribute value is null, then the next valid value will be the string "null" or whatever you set as the last valid value. This will make sure you don't get any errors.

This also comes in handy when defining the conditional statement for the value of the static transform. I often write these statements starting with the null argument, as seen below:

"value": "#if($workerType!=\"null\")$workerType#{else}Contingent#end"

In addition to my reply above, I wanted to provide some helpful tips that I have learned over time while utilizing static transforms, as the static transform is incredibly useful for some more conditional and complex logic.

 

Operators:

Equals

==

Example:

#if($variableOne==\"True\")True#{else}False#end

 

Does not Equal

!=

Example:

#if($variableOne!=\"True\")Not True#{else}True#end

 

And

&&

Example:

#if($variableOne!=\"null\" && $variableOne==\"True\")True#{else}False#end

 

Or

|| (two pipes)

Example:

#if($variableOne==\"null\" || $variableOne==\"False\")False#{else}True#end

 

Another tip I would mention is that you can use else-if statements with static transforms as well.  I have used fairly extensive if/else-if statements, and a few examples are below:

"value": "#if($newEmail==\"null@emaildomain.com\")none#elseif($ADEmail==\"null\" || $ADEmail==\"none\")$newEmail#{else}$ADEmail#end"

"value": "#if($firstName!=\"Null\" && $lastName!=\"Null\")$firstName $lastName#{else}NO NAME GENERATED#end"

"value": "#if($userStatus!=\"active\" && $userStatus!=\"null\")$disabledOU#elseif($deptOU!=\"null\")$deptOU#{else}#end"

"value": "#if($userStatus==\"active\" || $userStatus==\"null\")$userDepartment#elseif($userStatus==\"loa\" || $userStatus==\"litigationhold\")$LOAorLHDescription#{else}$disableDescription#end"

 

In terms of operators, I don't know if there is an operator for "contains" or "like," but if anyone else knows how that would work, please let me know; I would love to learn!

I believe any of the StringUtils classes should work, including "contains". For example: 

#if($search.contains("google"))google#{else}nothing#end

 

@justinrhaines that's awesome! Thanks for the response; I'll give this a try.

@Brennen Thank you for your response and the information you provided is very much handy for someone starting with these transforms. 

We did the same workaround of using firstvalid transforms to circumvent this issue. 

Regards,

VK.

May be a stupid question, but how does one return a true null out of a firstValid?  (Not a string "null").  I.e., after the transform if nothing worked I want the identity attribute to be null.

Hey @rkunditch,

The method I have used is in the "value" attribute/statement logic, where you define the actual value to use depending on the conditions defined. If I want a "true null" value, I just leave the "then" statement empty, such as:

"value": "#if($testValue==\"TRUE\")TRUE#{else}#end"

This will return a null or "(empty)" value.

Another method is to actually define a null variable, such as:

{
    "name": "BTS_Test_Static",
    "type": "static",
    "attributes": {
        "fn": {
            "attributes": {
                "name": "firstname"
            },
            "type": "identityAttribute"
        },
        "null": {
            "attributes": {
                "value": ""
            },
            "type": "static"
        },
        "value": "#if($fn==\"Jason\")TRUE#{else}$null#end"
    }
}

 

One issue that I see with this, however, is that the attribute value still shows up in the Identity Attributes list, despite having no content. I wish there was a way to hide the attribute from the Identity Attributes list if the value is null... maybe there is a way to do this and I just don't know about it yet.

Also @rkunditch, the Transform Operations documentation on Compass is being removed here soon, as it has been moved to the Developer Docs page. You can access it here:

https://developer.sailpoint.com/docs/transforms/transform_operations/transform_operations.html#trans...

Thanks @Brennen 

Version history
Revision #:
3 of 3
Last update:
‎Dec 09, 2021 05:19 PM
Updated by:
 
Contributors