27 day expire Mark Transform

I am having trouble try to get the condition met to display if an account is older than 27-day display after the expire date to display 27 or leave it blank. For some reason i cannot get the output to display the 27 mark on the accounts. Can anyone see the problem

  "name": "SNOW DATE Test",
    "type": "static",
    "attributes": {
        "requiresPeriodicRefresh": "true",
        "inactivestate": {
            "attributes": {
                "firstDate": "now",
                "secondDate": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "accountExpires",
                                            "sourceName": "ACTIVE DIRECTORY NON-EMPLOYEE ACCOUNT SOURCE"
                                        }
                                    },
                                    "inputFormat": "yyyyMMddssssss",
                                    "outputFormat": "MM/dd/yyyy"
                                },
                                "type": "dateFormat"
                            },
                            {
                                "attributes": {
                                    "expression": "now+27d/d",
                                    "roundUp": false
                                },
                                "type": "dateMath"
                            }
                        ]
                    }
                },
                "operator": "GT",
                "positiveCondition": "yes",
                "negativeCondition": "no"
            },
            "type": "dateCompare"
        },
        "value": "#if($inactivestate=='yes')Day 27#{else}#end"
    },
    "internal": false
}

Hello,

I would recommend trying ISO8601 format as the output format instead of MM/dd/yyyy. Example

{
    "name": "SNOW DATE Test",
    "type": "static",
    "attributes": {
        "requiresPeriodicRefresh": "true",
        "inactivestate": {
            "attributes": {
                "firstDate": "now",
                "secondDate": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "accountExpires",
                                            "sourceName": "ACTIVE DIRECTORY NON-EMPLOYEE ACCOUNT SOURCE"
                                        }
                                    },
                                    "inputFormat": "yyyyMMddssssss",
                                    "outputFormat": "ISO8601"
                                },
                                "type": "dateFormat"
                            },
                            {
                                "attributes": {
                                    "expression": "now+27d/d",
                                    "roundUp": false
                                },
                                "type": "dateMath"
                            }
                        ]
                    }
                },
                "operator": "GT",
                "positiveCondition": "yes",
                "negativeCondition": "no"
            },
            "type": "dateCompare"
        },
        "value": "#if($inactivestate=='yes')Day 27#{else}#end"
    },
    "internal": false
}
2 Likes

I agree with @jrote01 that you should be using ISO8061 format as that is what the DateCompare will operate on.

Additionally, i would set an Else value in your velocity template to validate it is being called correctly.

Also, for suture reference, when posting your code to the forum, use the Code tags so that it keeps the formatting and displays like Jeff’s example does.

So i gave this a go and am getting no errors. However, I am getting the output of Blank for both less then 27 days or more than 27 days for any accounts which is not doing the calculation for some reason correct . Here is the preview which is the correct ISO coming in but … UGH You can see this user is Plus 27th days which then should mark it 27 days but it not… These math conversions are the pain

image

So first, just to clarify, you want the attribute to be blank if the user is active (ie no accountExpire date), or the accountExpire date is less than 27 days ago (ie The account has not been expired for 27 days yet.) When the accountExpire date is more than 27 days ago (ie The account has been expired for 27+ day) you want it to display the “Day 27” value in the field. Is that correct?

If so, I think there is an error with your math. Looking at your original version from the first post:

(Adding here with Formatting)

{
  "name": "SNOW DATE Test",
  "type": "static",
  "attributes": {
    "requiresPeriodicRefresh": "true",
    "inactivestate": {
      "attributes": {
        "firstDate": "now",
        "secondDate": {
          "type": "firstValid",
          "attributes": {
            "values": [
              {
                "attributes": {
                  "input": {
                    "type": "accountAttribute",
                    "attributes": {
                      "attributeName": "accountExpires",
                      "sourceName": "ACTIVE DIRECTORY NON-EMPLOYEE ACCOUNT SOURCE"
                    }
                  },
                  "inputFormat": "yyyyMMddssssss",
                  "outputFormat": "MM/dd/yyyy"
                },
                "type": "dateFormat"
              },
              {
                "attributes": {
                  "expression": "now+27d/d",
                  "roundUp": false
                },
                "type": "dateMath"
              }
            ]
          }
        },
        "operator": "GT",
        "positiveCondition": "yes",
        "negativeCondition": "no"
      },
      "type": "dateCompare"
    },
    "value": "#if($inactivestate==‘yes’)Day 27#{else}#end"
  },
  "internal": false
}

You are setting the first date to NOW.

The Second date you are taking the firstValid from:

  • The accountExpires Account Attribute
  • NOW+27

You are then using Greater Than to check in the following format:

firstDate > secondDate

In the case of an active user with the accountExpire date not set, the check would be:

NOW > NOW+27d

Which will always be false.

If the user has the accountExpire value set, the check would be the following:

NOW > accountExpire

In this case, this will be false while the user is active, and true as soon as the user is inactive.

What I think you want to do is compare if the accountExpire is greater then NOW-27d:

firstDate: NOW-27d/d
secondDate: firstValid: accountExpire or NOW
operator: GT

NOW-27d/d > accountExpire

Now, if I misunderstood and you need the 27 to be 27 days before they go inactive, then you can just modify accordingly. Just note that if the accountExpires is set less than 27 days in advance, it would be set as soon as the conditions are met.

Additionally, I would step back and build the transform in stages. Start with the Date Compare and get it to return “yes” or “no” correctly, so you know your math is right and the compare is correct. Once you have that, then add the additional pieces in for the static value and the velocity template.

One last thing, in your screenshots you have a date of 6/13/2024, which is only 25 days from today (7/8/2024).

3 Likes

Fully agreeing with the above statement, but also to note that in your snippet, the date is NOT in ISO8601 format:

image

Hi, Geoff,

This is really informative and thank you. So you basiclly your where right on your thoughts of the 27 days, The user is a contractor so they will always have an expire date that is comming from AD “accountexpires” When that date is reached and it goes past the 27 date mark the user has to get that one feild with the string vaule of “Day 27” to let us know that account is in the system 27 days past the expire date. Later they want to add more days and then a powershell that removes them but for now its just a note on the account.

That format is Epoch32 correct as its comming directly from AD with no formatting?

Morning, I must have mis-understood the above sentence. I thought that you were saying that it was coming in as ISO. Sorry for any confusion

Do not be sorry for anything. Your help is very grateful. The above transform worked however one thing i did is use the identity attribute over using the source. This way I can format the date the way it needed to be processed. I will post the solution for everyone review as well since this could be a great help for things like the workflow i am working on related to creating tickets and notifications on leaver

What was the solution for this?

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