Question
· Jan 20, 2021

String manipulation on a field during transformation using a ClassMethod.

I need to do some nifty string manipulation on a source property. I will not be able to do it with the functions available(with the knowledge that I have of what is available). Could I call a ClassMethod to do this for me? This is what I want to do: The source property is "myemail@myemaildomain.co.uk". I need to add the text "test" to the beginning of that string. "testmyemail@myemaildomain.co.uk". That should be simple enough, but then I have to do this as well, "testmyemail@myemaildomaintest.co.uk". Note the additional "test" added after "myemaildomain".

Discussion (7)1
Log in or sign up to continue

Hey Werner.

I know I have ignored your request on how to call a class method (Jeffery has you covered by the looks of things), but you could use $PIECE to break the string apart and then insert what you need.

For example if "source.{PhoneNumberHome(1).Emailaddress}" is equal to "myemail@myemaildomain.co.uk" then 

"test"_$PIECE(source.{PhoneNumberHome(1).Emailaddress},".",1)_"test"_"."_$PIECE(source.{PhoneNumberHome(1).Emailaddress},".",2,*)

will return: 

"testmyemail@myemaildomaintest.co.uk"

The idea being that we

  • Start the new string with "test"
  • take everything before the first period with $P(source.{PhoneNumberHome(1).Emailaddress},"."1) 
  • Add "test" in again
  • Add a period that gets dropped from the $PIECE from using the period as the delimiter
  • Provide everything from the second period onwards with $P(source.{PhoneNumberHome(1).Emailaddress},".",2,*)