Replace Use Example
Basic Use Example
Replace is a fairly simple service to understand and use. In the example given below, we simply create three textboxes. One for each of the inputs that we are going to provide the service.
Once we press the “Replace” button, it simply takes the inputs from the fields and runs the Replace service as per the logic specified. It replaces all the instances of ‘is’ in the InputString with the characters ‘as’. Then in the logs it will generate an OutputString with can be used by a later service to set the value of the last field.
Notice in the output there were 4 old values replaced with the new value. If the user only wished to replace the word “is” and not the letters “i-s” within other words, the input value could have been padded in space characters: “ is “.
Using Replace to Format Currency Values
Often times when currency is displayed on a webpage, it is formatted for the user. It will have dollar signs and commas or decimals. These will have to be removed if we want the currency value to be saved as an integer in a database or passed into a function which requires the integer data type.
In this example, a page called “Proceed To Pay” takes some currency values from the page and inputs them into another function which will proceed to pay the invoices the user has selected. Two of these values are the TotalAmount and OpenAmount. Below you can see part of the process canvas.
Two Replace services are being used to format the numbers by removing the commas out of larger numbers. It is replacing the comma with a blank value, or an empty string.
This blank values was created by clicking into the NewValue parameter, then looking under the “Recommended Values” in the right panel.