Question

Is it possible in AX 2012 to find a particular word/words written in a string type field in AX 2012 table or form. e.g, I have a field named Memo in my table named test. In that field I have a written a text as: Hello, We need to confirm you that your < mobileNumber > is successfully attached with your account no. < Account >.

Now, I need to find all texts written inside tags "<" and ">". Furthermore I require to replace these texts according to my need. Please tell if its possible in AX 2012 or if there is any other option that I can opt to fulfill my need.

Was it helpful?

Solution

You can find every occurence of "<" and ">" using the strScan function http://msdn.microsoft.com/en-US/library/aa866529(v=ax.50).aspx

Use that to find the location of the "<"s and matching ">"

Use SubStr http://msdn.microsoft.com/en-US/library/aa677836(v=ax.50).aspx to find what is between "<" and ">", and apply your replacement based on that (using strPoke http://msdn.microsoft.com/en-US/library/aa850123(v=ax.50).aspx)

A useful AX2009 string class that utiliseses these methods and that may be of some help can be found here http://axgeek.blogspot.co.uk/2010/04/string-function-class.html , it should not take much effort to convert to 2012.

Of particular interest to you is the replace method.

However it may be simpler to have the memo as "Hello, We need to confirm you that your %1 is successfully attached with your account no. %2.", and to insert the values using strFmt http://www.axaptapedia.com/index.php?title=StrFmt

Of course the .Net String.Replace method is also available. see http://msdn.microsoft.com/en-us/library/cc584291.aspx and http://msdn.microsoft.com/en-us/library/system.string.replace.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top