Advanced String Replace Function
Using the built-in string functions in Dynamics NAV usually gives you all the string manipulation options you need. But a common request is replacing a special char with a new string value. This example came from the previous post on SMTP Mail functionality in Pre Dynamics NAV 5 versions. Mads from Denmark, ran into an issue with HTML encoding when using national chars like: æøåÆØÅ. For some reason the HTML emails worked fine at my local computer, here with US locale settings, but changing the values to their HTML encoded equivalent might be a good idea to get better compatability.
Below you will find the simple function for doing this.
Here is a simple example of how to HTML encode my name:
t := 'Søren'; message(t); InsertVariableValue(t,'ø','ø'); message(t); InsertVariableValue(VAR Formula : Text[30];VariableName : Text[30];VariableValue : Text[30]) WHILE STRPOS(Formula,VariableName) <> 0 DO BEGIN Pos := STRPOS(Formula,VariableName); Formula := DELSTR(Formula,Pos,STRLEN(VariableName)); Formula := INSSTR(Formula,DELCHR(FORMAT(VariableValue),'=',','),Pos); END;
This function was previously discussed in this post: Evaluate Formulas in Dynamics NAV and also on numerous posts on Mibuso and DynamicsUser. Hope you can use this Mads, and also you other readers .
This was originally posted here.
*This post is locked for comments