Null pointer exception

Hi,

I’m trying to use datecompare transform. I’m receiving null pointer exception for below transform. Not all the users have lastlogon value. only few users have, so I’m getting expected values after applying transform for users who have lastlogon. But i’m receiving null pointer exception for users who has no lastlogon value.

Can someone help me to correct the error.

{
                "attributes": {
                    "negativeCondition": "FUTUREDATE",
                    "positiveCondition": "PASTDATE",
                    "firstDate": {
                        
                                "attributes": {
								
                                                "id": "Example_Testlogon"
                                            },
                                            "type": "reference"
                                        },
                                       
                            
                    "operator": "GT",
                    "secondDate": {
                        "attributes": {
                            "expression": "now-0d",
                            "roundUp": false
                        },
                        "type": "dateMath"
                    }
					"ignoreErrors": "true",
                },
                "type": "dateCompare"
				"name": "IHDATE_Testlogon"
            },

{
		"name": "Example_Testlogon",
        "type": "firstValid",
        "attributes": {
            "ignoreErrors": "true",
            "values": [
                {
                  
	
  
      "attributes": {
        "expression": "+45d",
        "input": {
          "attributes": {
            "input": {
              "attributes": {
                "attributeName": "lastLogonTimestamp",
                "sourceName": "AD Test"
              },
              "type": "accountAttribute"
            },
            "inputFormat": "EPOCH_TIME_WIN32",
            "outputFormat": "ISO8601"
          },
          "type": "dateFormat"
        },
        "roundUp": true
      },   
	  "type": "dateMath"
                },
                ""
            ]
        },
        "internal": false
    }

If you are referencing account attributes that can be null, it is best practice to wrap your account attribute in a first valid operation: First Valid | SailPoint Developer Community. First valid will allow you to specify a default value in the event an account attribute is null. This default value could be an empty string, for example. This will get you past the null pointer exception, but you’ll still need to handle the default value appropriately.

1 Like

@colin_mckibben

Thanks a lot :slightly_smiling_face: :slightly_smiling_face:

I had fixed the null pointer exception using first valid transform.

{
			"name": "IH_Testlogon"
			"attributes":{
			"values":[
			{
			
                "attributes": {
                    "negativeCondition": "FUTUREDATE",
                    "positiveCondition": "PASTDATE",
                    "firstDate": {
                        
                                "attributes": {
								
                                                "id": "Example_Testlogon"
                                            },
                                            "type": "reference"
                                        },
                                       
                            
                    "operator": "GT",
                    "secondDate": {
                        "attributes": {
                            "expression": "now-0d",
                            "roundUp": false
                        },
                        "type": "dateMath"
                    }
					"ignoreErrors": "true",
                },
                "type": "dateCompare"
				
            },
			{
								"attributes": {
									"value": ""
									},
									"type": "static"
								}
								]
								}
								"type": "firstValid",
								}