Conditional Transforms for Contractor expiration

   {
        "name": "New Contract Expiration Check Transform1",
        "type": "conditional",
        "attributes": {
            "firstDateabc": {
                "attributes": {
                    "values": [
                        {
                            "attributes": {
                                "input": {
                                    "attributes": {
                                        "sourceName": "New_Source_CNexpTest",
                                        "attributeName": "CONTRACT_END_DATE"
                                    },
                                    "type": "accountAttribute"
                                },
                                "inputFormat": "MM/dd/yyyy",
                                "outputFormat": "ISO8601"
                            },
                            "type": "dateFormat"
                        }
                    ]
                },
                "type": "firstValid"
            },
            "secondDate": {
                "attributes": {
                    "input": "",
                    "expression": "now+14d",
                    "roundUp": false
                },
                "type": "dateMath"
            },
            "expression": "$secondDate eq $firstDate",
            "positiveCondition": "true",
            "negativeCondition": "false"
        },
        "internal": false
    }

This transform should return true if the input for the “CONTRACT_END_DATE” is a date that is exactly 14 days ahead from the current date. But it is returning false even when condition is satisfied. My input format is ‘MM/dd/yyyy’ (6/30/2023). Output is flase for all cases

Conditional transforms work better for comparing static/string attributes. For comparing dates please use the Date Compare transform.

1 Like

Is there any way for transform to return the difference between dates since DateCompare does not have condition for equal (it has lte, lt, gte and gt)

No, the transforms don’t return the date difference, they will just return a value based on positive/negative condition being met.

I want to compare if two dates are equal. How can i do this?

Apologize for not understanding that requirement earlier, i thought you just wanted to compare dates. For checking if dates are equal you an use your earlier transform with some changes.
In your transform the date formats were not matching hence it might be evaluating to false.

Please try the transform below:

{
    "name": "New Contract Expiration Check Transform1",
    "type": "conditional",
    "attributes": {
        "firstDate": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "sourceName": "New_Source_CNexpTest",
                                    "attributeName": "CONTRACT_END_DATE"
                                },
                                "type": "accountAttribute"
                            },
                            "inputFormat": "MM/dd/yyyy",
                            "outputFormat": "ISO8601"
                        },
                        "type": "dateFormat"
                    }
                ]
            },
            "type": "firstValid"
        },
        "secondDate": {
            "attributes": {
                "input": {
                    "attributes": {
                        "expression": "now+14d",
                        "roundUp": false
                    },
                    "type": "dateMath"
                },
                "inputFormat": "yyyy-MM-dd'T'HH:mm",
                "outputFormat": "ISO8601"
            },
            "type": "dateFormat"
        },
        "expression": "$secondDate eq $firstDate",
        "positiveCondition": "true",
        "negativeCondition": "false"
    },
    "internal": false
}

Just tried this. It is still returning false for input ‘6/30/2023’ which should be true. Does conditional work for dates?

May I suggest to use dateCompare transform twice, once as gte and another as lte. Then read the results from both. If both are positive, then equals will be true

Something like this…

{
    "name": "DateEqualsTransform",
    "type": "conditional",
    "attributes": {
        "expression": "$lteComparison$gteComparison eq truetrue",
        "positiveCondition": "true",
        "negativeCondition": "false",
        "lteComparison": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "attributes": {
                                "sourceName": "New_Source_CNexpTest",
                                "attributeName": "CONTRACT_END_DATE"
                            },
                            "type": "accountAttribute"
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateMath",
                    "attributes": {
                        "expression": "now+14d/d",
                        "roundUp": false
                    }
                },
                "operator": "lte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "gteComparison": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "attributes": {
                                "sourceName": "New_Source_CNexpTest",
                                "attributeName": "CONTRACT_END_DATE"
                            },
                            "type": "accountAttribute"
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateMath",
                    "attributes": {
                        "expression": "now+14d/d",
                        "roundUp": false
                    }
                },
                "operator": "gte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        }
    }
}

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