Query on Date Compare Transform

I need to have a transform where it will compare the date based on hire date from account attribute and a static date. If hire date(firstDate) is less than equal to static date(secondDate) then return yes else return HireDate. If boolean value is yes then return startDate identity attribute.

When it is suppose to return StartDate and startDate identity attribute then it is returning static value from StartDate. Below scenarios would make it clear.

  1. If hire date is 06/12/2017 which is smaller than static date 05/28/2021(secondDate) then it will meet this condition #if($isNewStartDate == ‘Yes’)$StartDate.
    Current startDate(identityAttribute) is lets say 2017-08-01 then it should have retain the value and return 2017-08-01 but start date is becoming static value of startDate i.e 2020-05-20.

    • Not Expected
  2. If hire date is empty then output is 2020-05-20. - Expected

  3. If hire date is 07/31/2024 then output is 2024-07-31 - Expected

Can anyone please suggest why scenario 1 is not working as expected?

Please find below the transform.

{
    "name": "StartDate",
    "type": "static",
    "attributes": {
        "StartDate": {
            "attributes": {
                "input": {
                    "attributes": {
                        "values": [
                            {
                                "attributes": {
                                    "attributeName": "startDate"
                                },
                                "type": "identityAttribute"
                            },
                            "2020-05-20"
                        ]
                    },
                    "type": "firstValid"
                },
                "inputFormat": "yyyy-MM-dd",
                "outputFormat": "yyyy-MM-dd"
            },
            "type": "dateFormat"
        },
        "hireDate": {
            "attributes": {
                "input": {
                    "attributes": {
                        "attributeName": "HireDate",
                        "sourceName": "Some Source"
                    },
                    "type": "accountAttribute"
                },
                "inputFormat": "MM/dd/yyyy",
                "outputFormat": "yyyy-MM-dd"
            },
            "type": "dateFormat"
        },
        "isNewStartDate": {
            "attributes": {
                "negativeCondition": "No",
                "positiveCondition": "Yes",
                "firstDate": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "attributeName": "HireDate",
                                            "sourceName": "Some Source"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "06/21/2018"
                                ]
                            },
                            "type": "firstValid"
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "secondDate": {
                    "attributes": {
                        "input": "05/28/2021",
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "operator": "lte"
            },
            "type": "dateCompare"
        },
        "value": "#if($isNewStartDate == 'Yes')$StartDate#{else}$hireDate#end"
    },
    "internal": false
}

@Amrit1897 try with following, I know it’s wired but it works for me.

“value”: “#if($isNewStartDate == \"Yes\")$StartDate#{else}$hireDate#end”

Regards,
Shekhar Das

1 Like

@Amrit1897 The code works fine for me. Looks like the code you given has some validation issue like invalid Single and Double quotes. I have share the formatted file here.
StartDate Transform.json (2.9 KB)

Regards,
Shantha Kumar

or possibly it’s that your date format is wrong for the startDate variable:

    "StartDate": {
      "type": "dateFormat",
      "attributes": {
        "input": {
          "type": "firstValid",
          "attributes": {
            "values": [
              {
                "attributes": {
                  "attributeName": "startDate"
                },
                "type": "identityAttribute"
              },
              "05/20/2020"      <= this is MM/dd/yyyy
            ]
          }
        },
        "inputFormat": "dd/MM/yyyy",      <= should this be MM/dd/yyyy?
        "outputFormat": "yyyy-MM-dd"
      }
    }

Don’t forget to encapsulate your code with ``` so that it formats correctly on here

Phil

1 Like

Hi Phill, It was mistake while asking. I have updated my ask.

Hi @Amrit1897 i don’t understand you 1. condition that is when do you want to populate the already present identity attribute date ??

But i do understand that you want to have the existing Identity attribute date also displayed. In that case i will say add few more snippets in the transform for $oldValue and its checks.

I am attaching the sample snippet below.

"priorValue": {
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "value": "$oldValue"
                },
                "type": "static"
            },
            {
                "attributes": {
                    "value": "N/A"
                },
                "type": "static"
            }
        ]
    }
},
"todayDate": {
    "type": "dateFormat",
    "attributes": {
        "input": {
            "type": "dateMath",
            "attributes": {
                "input": "",
                "expression": "now",
                "roundUp": false
            }
        },
        "inputFormat": "yyyy-MM-dd",
        "outputFormat": "yyyy-MM-dd"
    }
},
"value": "#if($priorValue != 'N/A')$priorValue#else$todayDate#end" //here add additional check for where you require your existing date to be populated what is that condition.

Did the identity attribute have the value 2017-08-01 before you started testing the transform? Any values assigned to identity attributes while previewing the transform results are temporary only and will not be available for the next preview. Based on your transform, only reason for you to get the date as ‘2020-05-20’ can be current startDate for the identity is empty

Yes, 2020-05-20 is coming when startDate is empty.
But 2020-05-20 is also coming when startDate is 2017-08-01.

okay… here is the issue
Your transform:
image

Correct format:
image

It’s "name", not "attributeName" inside attributes block of an Identity Attribute transform

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