Hi,
Is it possible to add 2 numbers in transforms. We have a string (account attribute). I want to create a transform to add 1 to account attribute value and populate in IDN attribute
Hi,
Is it possible to add 2 numbers in transforms. We have a string (account attribute). I want to create a transform to add 1 to account attribute value and populate in IDN attribute
Hi @chandramohan27
Yes, that is indeed possible, you can use Integer class to do that.
I will paste a pseudocode for that and you can procced further to build on it as per your requirements.
"stringNum":{
//get value from account Attributes
},
"displayName":{
//Get value from account Attributes
},
"value":"
#set($Integer=0)
#set($intNum=$Integer.parseInt($stringNum))
#set($inc=1)
#set($newNumber=$inc+$intNum)$displayName[$newNumber]
"
P.S the type of the transform would be string.
Hope this helps ![]()
I believe you can Use “Long” class
Are you working with a date value? If so, you could use the dateFormat transform to convert the string to ISO8601, then add the interval you’re looking to add using a dateMath transform, then use another dateFormat to convert it back to the desired format.
I’m using a Long int value for calculation.
this not little bit clear here, you are telling adding two numbers and at the same time you said have string account attribute, if it is string attribute and want to add 1 to that attribute, it is very simple as:
{
"attributes": {
"value": "1"
},
"type": "static"
}
have concat type I am assuming you know well how to call account attribute in transform.
Also am not sure what you are mean to add two numbers here?
we have a account attribute value : 202500020098 (which is long int). Now we want to add an int value : 1 to it.
expected result = 202500020099
in that case use like this:
{
"attributes": {
"expression": "+X",
"input": {
"attributes": {
"sourceName": "source name enter here",
"attributeName": "attribute name enter here please"
},
"type": "accountAttribute"
}
},
"type": "dateMath",
"name": "Add Integer to Long Integer"
}
replace X with 1 or any number you want to add
Hello Mohan,
So during account creation, you want to a add 2 numbers into a String attribute and then, get it populated back to Identity Profile once the identity is created?
Regards,
Rohit Wekhande.
this isn’t going to work if it’s not a date formatted in ISO8601. you’re also not specifying the interval to add. you can’t use a dateMath transform just to do math to strings.
I’d encourage everyone here to upvote this Idea in the Ideas Portal to support the Velocity dateTool and numberTool packages in Transforms, which would greatly simplify this: https://ideas.sailpoint.com/ideas/GOV-I-4029
You can use the below transform to achieve addition of 2 numbers using transform that are (long int’s)
"stringNum":{
//get value from account Attributes
},
"displayName":{
//Get value from account Attributes
},
"value":"#set($Long=202500020098)#set($val=$Long.parseLong(\"stringNum\"))#set($inc=1)#set($newVal = $val+$inc)$newVal"
NOTE:
you can see that $Long is set as the value you gave as an example, but that actually does not affects anything you have to use any value that is a long int to make sure that parsing happens properly.
Hope this helps ![]()
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.