Hi Team,
I am trying the below dateCompare transform and it is working fine for me. However if BEGDA value is null this transform is throwing me error. Can you please help me with this?
{
"type": "dateCompare",
"name": "BEGDA date Check",
"attributes": {
"firstDate": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "dateMath",
"attributes": {
"expression": "now"
}
},
"inputFormat": "yyyy-MM-dd'T'HH:mm",
"outputFormat": "ISO8601"
}
},
"secondDate": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "accountAttribute",
"attributes": {
"sourceName": "SAP HR - Development 2",
"attributeName": "BEGDA"
}
},
"inputFormat": "yyyyMMdd",
"outputFormat": "ISO8601"
}
},
"operator": "gt",
"positiveCondition": "true",
"negativeCondition": "false"
}
}
How can i perform a null check for this transform?
dheerajk27
(dheeraj kumar)
August 4, 2023, 10:34am
2
Sindhu V Murthy:
I am trying the below dateCompare transform and it is working fine for me. However if BEGDA value is null this transform is throwing me error. Can you please help me with this?
{
“type”: “dateCompare”,
“name”: “BEGDA date Check”,
“attributes”: {
“firstDate”: {
“type”: “dateFormat”,
“attributes”: {
“input”: {
“type”: “dateMath”,
“attributes”: {
“expression”: “now”
}
},
“inputFormat”: “yyyy-MM-dd’T’HH:mm”,
“outputFormat”: “ISO8601”
}
},
“secondDate”: {
“type”: “dateFormat”,
“attributes”: {
“input”: {
“type”: “accountAttribute”,
“attributes”: {
“sourceName”: “SAP HR - Development 2”,
“attributeName”: “BEGDA”
}
},
“inputFormat”: “yyyyMMdd”,
“outputFormat”: “ISO8601”
}
},
“operator”: “gt”,
“positiveCondition”: “true”,
“negativeCondition”: “false”
}
}
How can i perform a null check for this transform?
To handle the case when the attribute “BEGDA” is null, you can use the “nullSafe” function in the attribute configuration for “secondDate.” The “nullSafe” function allows you to specify a default value that will be used in case the attribute is null. In this case, you can set a default value representing the minimum date (e.g., “0001-01-01”) or any other appropriate value for your use case.
Here’s how you can modify the “secondDate” attribute configuration to perform a null check and provide a default value:
{
"type": "dateFormat",
"attributes": {
"input": {
"type": "nullSafe",
"attributes": {
"value": {
"type": "accountAttribute",
"attributes": {
"sourceName": "SAP HR - Development 2",
"attributeName": "BEGDA"
}
},
"defaultValue": "0001-01-01" // Provide a default value for BEGDA when it's null
}
},
"inputFormat": "yyyyMMdd",
"outputFormat": "ISO8601"
}
}
With this modification, if the “BEGDA” attribute is null, it will use the default value “0001-01-01” instead, and the dateCompare transform should work without throwing an error in such cases.
1 Like
Hi @dheerajk27 ,
I did try the same thing as you suggested, still i am getting the below error.
Below is the transform that i have updated and used.Please let me know if there is something wrong with this.
{
"type": "dateCompare",
"name": "BEGDA Greater than Check",
"attributes": {
"firstDate": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "dateMath",
"attributes": {
"expression": "now"
}
},
"inputFormat": "yyyy-MM-dd'T'HH:mm",
"outputFormat": "ISO8601"
}
},
"secondDate": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "nullSafe",
"attributes": {
"value": {
"type": "accountAttribute",
"attributes": {
"sourceName": "SAP HR - Development 2",
"attributeName": "BEGDA"
}
},
"defaultValue": "00010101"
}
},
"inputFormat": "yyyyMMdd",
"outputFormat": "ISO8601"
}
},
"operator": "gt",
"positiveCondition": "true",
"negativeCondition": "false"
}
}
sharvari
(Sharvari Shah)
August 4, 2023, 11:09am
4
Modify the secondDate to include a firstValid transform.
"secondDate": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "firstValid",
"attributes": {
"values": [
{
"type": "accountAttribute",
"attributes": {
"sourceName": "SAP HR - Development 2",
"attributeName": "BEGDA"
}
},
"19000101",
]
}
}
},
"inputFormat": "yyyyMMdd",
"outputFormat": "ISO8601"
}
}
5 Likes
iamnithesh
(Nithesh Rao)
August 4, 2023, 12:19pm
6
quick note:
default value in the firstValid is not in the format yyyyMMdd
specified under "inputFormat": "yyyyMMdd"
1 Like
sharvari
(Sharvari Shah)
August 4, 2023, 12:48pm
7
Thanks, edited it in post above.
1 Like
Hi @sharvari ,
I have tried the below transform and im still getting error.
Here is the code snippet
{
"type": "dateCompare",
"name": "BEGDA Check",
"attributes": {
"firstDate": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "dateMath",
"attributes": {
"expression": "now"
}
},
"inputFormat": "yyyy-MM-dd'T'HH:mm",
"outputFormat": "ISO8601"
}
},
"secondDate": {
"type": "dateFormat",
"attributes": {
"input": {
"attributes": {
"values": [
{
"attributes": {
"sourceName": "SAP HR - Development 2",
"attributeName": "BEGDA"
},
"type": "accountAttribute"
},
"20400101"
]
},
"type": "firstValid"
}
},
"inputFormat": "yyyyMMdd",
"outputFormat": "ISO8601"
},
"operator": "gt",
"positiveCondition": "true",
"negativeCondition": "false"
}
}
iamnithesh
(Nithesh Rao)
August 5, 2023, 3:35pm
10
If you are getting null
for the transform output, it is most likely because the input value to dateFormat
transform is not in the inputFormat
you have specified. Can you reconfirm if the value of BEGDA
attribute in your source is in the format yyyyMMdd
2 Likes
Hi Nithesh,
I rechecked and I’m using the date format as “20230821”. Still this exception is coming up
iamnithesh
(Nithesh Rao)
August 11, 2023, 12:24pm
12
Try this for firstDate
"firstDate": {
"type": "dateFormat",
"attributes": {
"input": {
"type": "dateMath",
"attributes": {
"expression": "now/m",
"roundUp": false
}
},
"inputFormat": "yyyy-MM-dd'T'HH:mm",
"outputFormat": "ISO8601"
}
}
iamnithesh
(Nithesh Rao)
August 13, 2023, 5:59pm
13
Hi @sindhu_v_murthy
Were you able to resolve this issue? If so, would you please share the solution you found?
TIA
system
(system)
Closed
October 12, 2023, 6:00pm
14
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.