@yasserdex777 -
Here’s a straightforward way to think about how the workflow calculates the user’s end date:
-
Get the user’s current information
- The Get Identity step pulls the user’s data (including their
startDate
and the number of months that represent their end date, called endDateMonths
here).
- This data comes from
$.trigger.identity.id
, meaning it’s using the identity ID from the event that triggered this workflow.
-
Define Variables
-
Inside Define Variables, we create three variables:
- startDate
- Pulled from
$.getIdentity.attributes.startDate
.
- endDateMonths
- Pulled from
$.getIdentity.attributes.endDateMonths
(the user’s end date in “months” form, a numeric value).
- calculatedEndDate
- First uses the Add Time transform (
sp:transform:addTime:time
) to add endDateMonths
months to the startDate
.
- Then applies the Date Format transform (
sp:transform:formatDate:string
) to convert the date into a text format (YYYY-MM-DD
).
- In other words, it says: “Take the startDate, add the specified number of months to it, then convert that updated value into a YYYY-MM-DD format.”
-
The result of this is a nicely formatted date in calculatedEndDate
.
-
Update Identity
- Once we have
calculatedEndDate
, the workflow updates the user’s record with this new “actual” end date.
- It does so by making a PATCH request (the
sp:http
action) to the IdentityNow API (https://api.identitynow.com/v3/identities
), sending along the new endDate
value from calculatedEndDate
.
- This means the user’s profile in IdentityNow will store a precise, calendar-based date rather than just a number of months.
-
Finish Up
- The workflow ends with End Step - Success once the identity record is updated.
Below is the full JSON, with each piece corresponding to the explanation above:
{
"name": "Transform User End Date",
"description": "Transforms the user end date from months to a specific date by adding the duration to the user's start date",
"modified": "2025-04-08T07:23:44.876934669Z",
"modifiedBy": {
"type": "IDENTITY",
"id": "902586a42cd3424a86bcc82a1a8697f6",
"name": "official.amit"
},
"definition": {
"start": "Get Identity",
"steps": {
"Get Identity": {
"actionId": "sp:get-identity",
"attributes": {
"id.$": "$.trigger.identity.id"
},
"displayName": "",
"nextStep": "Define Variables",
"type": "action",
"versionNumber": 2
},
"Define Variables": {
"attributes": {
"id": "sp:define-variable",
"variables": [
{
"name": "startDate",
"transforms": [],
"variableA.$": "$.getIdentity.attributes.startDate"
},
{
"name": "endDateMonths",
"transforms": [],
"variableA.$": "$.getIdentity.attributes.endDateMonths"
},
{
"name": "calculatedEndDate",
"transforms": [
{
"id": "sp:transform:addTime:time",
"input": {
"length.$": "$.endDateMonths",
"unit": "months"
}
},
{
"id": "sp:transform:formatDate:string",
"input": {
"dateFormat": "YYYY-MM-DD"
}
}
],
"variableA.$": "$.startDate"
}
]
},
"displayName": "",
"nextStep": "Update Identity",
"type": "Mutation"
},
"Update Identity": {
"actionId": "sp:http",
"attributes": {
"authenticationType": "OAuth",
"basicAuthPassword": "",
"basicAuthUserName": "testUser",
"headerAuthName": "password",
"headerAuthValue": "",
"jsonRequestBody": {
"attributes": {
"endDate.$": "$.defineVariables.calculatedEndDate"
},
"id.$": "$.trigger.identity.id"
},
"method": "patch",
"oAuthClientId": "client",
"oAuthClientSecret": "",
"oAuthCredentialLocation": "oAuthInHeader",
"oAuthScope": "NONE",
"oAuthTokenUrl": "https://devrel.api.identitynow.com",
"requestContentType": "json",
"requestHeaders": {
"TestHeader": "TestHeaderValue"
},
"url": "https://api.identitynow.com/v3/identities",
"urlParams": {
"limit": "2"
}
},
"displayName": "",
"nextStep": "End Step - Success",
"type": "action",
"versionNumber": 2
},
"End Step - Success": {
"displayName": "",
"type": "success"
}
}
},
"creator": {
"type": "IDENTITY",
"id": "902586a42cd3424a86bcc82a1a8697f6",
"name": "official.amit"
},
"trigger": {
"type": "EVENT",
"attributes": {
"id": "idn:identity-attributes-changed"
}
}
}
In simpler terms: The workflow’s core logic is to take the user’s start date, add a certain number of months, format that as a standard calendar date, and then update the user’s IdentityNow record. That way, the user’s end date is stored as a properly formatted date instead of just a numeric month count.
Hope this helps.