Change Part Number through Scripting

We are trying to take the Product Number displayed in the label below and if it has “S8” in the product number, we want the “S8” to be replaced with “SS” through the scripting. We are doing a query and scripting on the same label.
Does anybody have any insight as to how to take the Product Number and replace the “S8” with “SS”? Do I need a new label where the query is separate from the scripting? I have tried this and still can not get it to work. Thanks in advance.


The issue is that the query overwrites what the script is doing. Instead of a script, try using a replace() function in your query:

SELECT DISTINCT CASE WHEN PART_CODE = '{Root Container.PART_NUMBER.text}' THEN REPLACE(CUST_PART,'S8','SS') ELSE REPLACE('{Root Container.PART_NUMBER.text}','S8','SS') FROM cust_part

Thanks, Jordan. This worked out just like I was hoping. Appreciate the feedback. I added END after the ELSE REPLACE statement.

SELECT DISTINCT CASE WHEN PART_CODE = '{Root Container.PART_NUMBER.text}' THEN REPLACE(CUST_PART,'S8','SS') ELSE REPLACE('{Root Container.PART_NUMBER.text}','S8','SS') END FROM cust_part

You may want to check the execution plan of your query - depending on your database, without a WHERE clause it could be scanning the whole table and returning the '{Root Container.PART_NUMBER.text}' that you plug into the ELSE piece of your case statement once for each row, then filtering out the repeats. Could end up being a big performance issue if your table was very large.