# Transform to return NULL

**URL:** <https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233>\
**Category:** SHF Discussion and Questions\
**Tags:** transforms, sailpoint-identity-security\
**Created:** [February 13, 2024, 2:31pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233 "2024-02-13T14:31:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![edmarks](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/edmarks/32/2896_2.png) [@edmarks](https://developer.sailpoint.com/discuss/u/edmarks)\
**Post date:** [February 13, 2024, 2:31pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/1 "2024-02-13T14:31:42Z")

</div>

Does anyone know of a way to have a transform return NULL vs “empty string”?

The specific use case is a calculation of an identity attribute that needs to be set to NULL in certain conditions. Similar to reading a NULL, or empty string, from a source where the identity attribute doesn’t show at all on the identity page. Currently with the transform returning an empty string, the identity attribute shows but with an empty string (i.e. no value) and this is causing confusion.

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [February 13, 2024, 6:37pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/2 "2024-02-13T18:37:43Z")

</div>

Could you use a conditional to return `null`?

> **[Conditional | SailPoint Developer Community](https://developer.sailpoint.com/idn/docs/transforms/operations/conditional)**
>
> Output different values depending on simple conditional logic.

Maybe something like this:

```json
{
  "attributes": {
    "expression": "foo eq bar",
    "positiveCondition": foo,
    "negativeCondition": null
  },
  "type": "conditional",
  "name": "Conditional Transform"
}

```

---

<div class="post-metadata">

**Author:** ![edmarks](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/edmarks/32/2896_2.png) [@edmarks](https://developer.sailpoint.com/discuss/u/edmarks)\
**Post date:** [February 13, 2024, 7:12pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/3 "2024-02-13T19:12:32Z")

</div>

Tried that, but it didn’t seem to work. Examples and results shown below for reference:

```json
{
    "id": "990b8c62-967b-4b4a-8e88-60b376bc88f6",
    "name": "Identity_MiddleNameNewTest",
    "type": "conditional",
    "attributes": {
        "expression": "foo eq foo",
        "positiveCondition": "foo",
        "negativeCondition": "bar"
    },
    "internal": false
}

```

Result: foo

```json
{
    "id": "990b8c62-967b-4b4a-8e88-60b376bc88f6",
    "name": "Identity_MiddleNameNewTest",
    "type": "conditional",
    "attributes": {
        "expression": "foo eq foo1",
        "positiveCondition": "foo",
        "negativeCondition": "bar"
    },
    "internal": false
}

```

Result: bar

```json
{
    "id": "990b8c62-967b-4b4a-8e88-60b376bc88f6",
    "name": "Identity_MiddleNameNewTest",
    "type": "conditional",
    "attributes": {
        "expression": "foo eq foo",
        "positiveCondition": null,
        "negativeCondition": "bar"
    },
    "internal": false
}

```

Result: trackingId: b1ed626f37064385850b931bbe1986c5 sailpoint.api.AttributePromotionException: Applying transform[reference] to attribute[middleNameNew] failed

```json
{
    "id": "990b8c62-967b-4b4a-8e88-60b376bc88f6",
    "name": "Identity_MiddleNameNewTest",
    "type": "conditional",
    "attributes": {
        "expression": "foo eq foo",
        "positiveCondition": "",
        "negativeCondition": "bar"
    },
    "internal": false
}

```

Result: trackingId: 4a27b14521264e7eb7821a47ff93d704 sailpoint.api.AttributePromotionException: Applying transform[reference] to attribute[middleNameNew] failed

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [February 13, 2024, 8:03pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/4 "2024-02-13T20:03:15Z")

</div>

Ok, so maybe the conditional operator does some null checking to make sure nulls aren’t aggregated. The next option would be to use the static transform with some velocity scripting. Something like this.

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

```

---

<div class="post-metadata">

**Author:** ![iamology](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamology/32/6964_2.png) [@iamology](https://developer.sailpoint.com/discuss/u/iamology)\
**Post date:** [February 13, 2024, 9:01pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/5 "2024-02-13T21:01:04Z")

</div>

If a transform happens to return null, then it throws an Exception…

```auto
{
    "id": "a410048e-XXXXXXXXXXXX-169cafd41864",
    "name": "Test Transform",
    "type": "static",
    "attributes": {
        "value": "#set($foo = null)$foo"
    },
    "internal": false
}

```

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/1/19a8915c58e37d9b19ed7008166f48223e4e56a6.png)

---

<div class="post-metadata">

**Author:** ![Sivakrishna1993](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sivakrishna1993/32/25424_2.png) [@Sivakrishna1993](https://developer.sailpoint.com/discuss/u/Sivakrishna1993)\
**Post date:** [February 20, 2024, 7:02pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/6 "2024-02-20T19:02:51Z")

</div>

Hi

You can use first value Tranform along with static transform

Example:

```auto
{
    "name": "Testing",
    "type": "static",
    "attributes": {
        "workerType": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "attributeName": "empType",
                            "sourceName": "HR Source"
                        },
                        "type": "accountAttribute"
                    },
                    {
                        "attributes": {
                            "value": "NULL"
                        },
                        "type": "static"
                    }
                ]
            },
            "type": "firstValid"
        },
        "value": "#if($workerType=='Employee')Full-Time#{else}NULL#end"
    },
    "internal": false
}

```

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/e/e72acc578a479e82b3eef4fba0254159099db7bc.png)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/7/7e833b58c0363a1af4f774b78bb68c79f2dfe289.png)

---

<div class="post-metadata">

**Author:** ![edmarks](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/edmarks/32/2896_2.png) [@edmarks](https://developer.sailpoint.com/discuss/u/edmarks)\
**Post date:** [February 22, 2024, 3:59pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/7 "2024-02-22T15:59:57Z")

</div>

This definitely returns the STRING VALUE of “NULL”, but not the desired NULL value that is desired.

---

<div class="post-metadata">

**Author:** ![austin\_alexander](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@austin\_alexander](https://developer.sailpoint.com/discuss/u/austin_alexander)\
**Post date:** [March 4, 2024, 8:32pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/8 "2024-03-04T20:32:28Z")

</div>

I am having this same issue. Transforms don’t seem to like returning blank values.

---

<div class="post-metadata">

**Author:** ![brennenscott](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/brennenscott/32/23642_2.png) [@brennenscott](https://developer.sailpoint.com/discuss/u/brennenscott)\
**Post date:** [March 4, 2024, 9:32pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/9 "2024-03-04T21:32:48Z")

</div>

Hey @edmarks,

One solution as another mentioned is to use a STRING null rather than an empty string. That way, attributes with empty values are not displayed in the Identity Details page and at least say something like “NULL,” “EMPTY,” “N/A,” or whatever else you may see fit. However, to prevent the attribute from being displayed altogether, see the solution suggestion below.

# The Solution

If you want the attribute to not appear at all for identities that do not have a value in there, you can use the `firstValid` transform to accomplish this. An example is below:

```auto
{
    "name": "FirstValid_Null_Test",
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "attributeName": "Special Identifier",
                    "sourceName": "DLT HR Feed"
                },
                "type": "accountAttribute"
            },
            null
        ]
    }
}

```

This is a simple `firstValid` transform that may need to be adjusted to fit your needs, but you can combine this with whatever transforms you would like to accomplish this. As you can see in the screenshots below, the first user (Billy Goose) has a Special Identifier, which is shown in his Identity Details. However, the second user (Claire Williams) does not have this Special Identifier, which results in the `null` value being selected in the `firstValid` transform; because this is a true null value, the attribute is not displayed in Claire’s Identity Details.

## Billy Goose (Special Identifier displayed)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/b/bb245d205f0cab06de2546946f822feccb58f1ce.png)

## Claire Williams (no Special Identifier)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/5/508c9f37d49602a1dc21db2fc317f300acfe8054.png)

# Additional Feedback

Unfortunately, using the `static` transform and setting a variable as null will not work. Identity Security Cloud will render template errors upon null reference exceptions, and as far as I know, `static` cannot bypass this.

---

<div class="post-metadata">

**Author:** ![edmarks](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/edmarks/32/2896_2.png) [@edmarks](https://developer.sailpoint.com/discuss/u/edmarks)\
**Post date:** [March 7, 2024, 2:30pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/10 "2024-03-07T14:30:08Z")

</div>

This helps clarify there isn’t a solution if using the static transform as we’re doing in this case.

---

<div class="post-metadata">

**Author:** ![brennenscott](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/brennenscott/32/23642_2.png) [@brennenscott](https://developer.sailpoint.com/discuss/u/brennenscott)\
**Post date:** [March 7, 2024, 5:28pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/11 "2024-03-07T17:28:36Z")

</div>

Hey @edmarks,

Let me expand on this, because the solution I suggested may still work for you but would require some adjustment. You can use this `firstValid` transform workaround in tandem with the `static` transform. As you can see in my previous solution, I employed the use of only the `firstValid` transform, however, in my solution below, you can see the use of both.

# Solution

```auto
{
    "name": "FirstValid_Static_Null_Test",
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "calculatedValue": {
                        "attributes": {
                            "values": [
                                {
                                    "attributes": {
                                        "attributeName": "Special Identifier",
                                        "sourceName": "DLT HR Feed"
                                    },
                                    "type": "accountAttribute"
                                },
                                "null string"
                            ]
                        },
                        "type": "firstValid"
                    },
                    "null": null,
                    "value": "#if($calculatedValue!='null string')$calculatedValue#{else}$null#end"
                },
                "type": "static"
            },
            null
        ]
    }
}

```

# Explanation

What I did here is I simply took the `firstValid` transform I wrote in my previous solution and nested it in a `static` transform. This allows for the use of the `static` transform conditional logic and statements to be used, but in case of a null value, we return a true null. Initially, this would throw an error since the `static` transform will not appreciate the null reference exception. However, that `static` transform is also nested within another `firstValid` transform, which recognizes the error and determines the value is invalid, so it proceeds to the next valid value, which we identify as a **true null value**. This is then accepted by the transform and is placed in the identity attribute.

# Summary

With this, we accomplish the following:

- Conditional logic can be used with the static transform to determine the exact value we want
- For Identities **with valid values** in this attribute, the identity attribute will be displayed in their Identity Details page
- For Identities **without valid values** in this attribute, the identity attribute will be determined to be a **true null** , resulting in the identity attribute not being displayed at all in the Identity Details page.

Does this help clarify, and does this solution work for you?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [May 6, 2024, 5:29pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-return-null/30233/12 "2024-05-06T17:29:30Z")

</div>

Closed on May 6, 2024, 5:29pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
