Is it possible to add an integer value to GetIndexOf in Define Variable action step in a workflow? The issue is I’m trying to get an index position of starting number i.e. ‘1’(this can vary). I’m able to get the index of ‘-’, to this I need to add +2. For example, the index of ‘-’ is 4 now I need to add +2 which will become 6. If adding a value is not possible, is there any other way directly to get the index of ‘1’?
I don’t think numeric math is possible, but there is another way to work your problem. You can use regular expressions with the “Get Index” transform in the Define Variable Operator.
Assuming the pattern you have given as an example is ALWAYS followed, the simplest way to do this is to look for the position of the first digit ‘\d’ character class:
If you can’t guarantee the pattern: <All_alphabetic> - <Numeric>
Then you may need to do more complicated things (Unfortunately, AFAICT from my testing, more complicated regular expressions like those using lookbehind don’t work) but let me know if this solves your issue.
@sidharth_tarlapally I want to get the index of first character after ‘-’ for below examples. We are trying this in define variable action step in workflow.
3Series M - c85b3a2d7e5d46adb794b65437e14837
4Series C - f85b3a2d7e5ru466adb794b65437e1nf8
The requirement is that we want the index number of character which is next to the specified pattern character , i.e index of value 1 for the given example ABC-123 , which should be 4
So now , we either should able to add the integer with 1 or get directly the index value . but we cannot do it with available operators
Workaround
As we need the right next character index what we can do Is :
Define Variable A - Your Original Value ABC-123
Define Variable B - A static Text Value “Z” Z
Define Variable FinalString - Contact Variable A and Variable B gives ZABC-123
Now that we have an extra character preceding to original string , when we call : getIndex of - for FinalStringZABC-123 it would give 4, which is our desired output .
3Series M - c85b3a2d7e5d46adb794b65437e14837 getIndex('-') = 10, but the expected value is 11.
Now, by prefixing the string with 'A':
A3Series M - c85b3a2d7e5d46adb794b65437e14837
getIndex('-') becomes 11, which matches the expected value.
Similarly, for:
4Series CAM - f85b3a2d7e5ru466adb794b65437e1nf8 getIndex('-') = 12, but the expected is 13.
After adding 'A' at the beginning:
A4Series CAM - f85b3a2d7e5ru466adb794b65437e1nf8
getIndex('-') becomes 13, as expected.
Unless I’ve misunderstood the requirement, this method isn’t dependent on the total number of characters in the string. Since the goal is always to find the index immediately after the hyphen (-), and indexing starts at 0, we’re simply shifting the position by prepending a character before the hyphen.
It really helped. Thanks a lot @sidharth_tarlapally . It would be good if SailPoint support complex regex pattern in workflows particularly for “GetIndexOf” operation in Define Variable step.