String Replace Issue

Post Reply
rhd_ole
Member
Posts: 92
Joined: Mon Jan 24, 2022 5:36 pm

String Replace Issue

Post by rhd_ole »

Hello Switch World -

To keep this simple, I'm trying to make a URL that is web safe. So I need to remove the spaces and replace them with %20.

The URL is built from various privatedata values and some static info.. Only one privatedata value will ever contain spaces, "description" this is the string I need to change

After searching the forums, String Replace seemed to be the easy solution, however I don't get any results even when trying to replace a word such as "START" with "DONE"

My process and how String Replace is setup:
I'm looking to change the value in privatedata key "description". ( in my test the value is START this test )
Mode: Privat Data
Data: [Job.PrivateData:Key="description"
Separator: =
Strings: START=DONE
Global: Yes
Ignore case: Yes
Screenshot 2023-01-02 at 11.27.00 AM.png
Screenshot 2023-01-02 at 11.27.00 AM.png (52.49 KiB) Viewed 7971 times

The result is the same "START this test" vs what it should be "DONE this test" as the new privatedata.

Am I missing something or is there another way?
Color Science & Workflow Automation
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: String Replace Issue

Post by jan_suhr »

In the Property "Data" you should have the name of the Private Data key.

In other words it should just say "description"

Then if there is a value "START" in that Private data value you will get the result "DONE", otherwise nothing will happen.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
rhd_ole
Member
Posts: 92
Joined: Mon Jan 24, 2022 5:36 pm

Re: String Replace Issue

Post by rhd_ole »

jan_suhr wrote: Mon Jan 02, 2023 7:39 pm In the Property "Data" you should have the name of the Private Data key.

In other words it should just say "description"

Then if there is a value "START" in that Private data value you will get the result "DONE", otherwise nothing will happen.
I feel dumb now, but thank you very much. Of all the things I tried, this didn't cross my mind but makes total sense now that you pointed it out.

Works perfectly!!

Thanks again.
Color Science & Workflow Automation
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: String Replace Issue

Post by freddyp »

Another consideration is the following: the URL property of the "HTTP request" element takes the provided value as is, but the values of the Parameters property are automatically URL-encoded (replacing a space by %20 is only one of many replacements that can be done).

Concretely speaking, if you have to create a URL like https://mysite.com?param%201=value%201& ... =value%202 you can do that with:

URL: https://mysite.com?param%201=value%201& ... =value%202

or with:

URL: https://mysite.com
Parameters: param 1=value 1
param 2=value 2
rhd_ole
Member
Posts: 92
Joined: Mon Jan 24, 2022 5:36 pm

Re: String Replace Issue

Post by rhd_ole »

freddyp wrote: Tue Jan 03, 2023 8:59 am Another consideration is the following: the URL property of the "HTTP request" element takes the provided value as is, but the values of the Parameters property are automatically URL-encoded (replacing a space by %20 is only one of many replacements that can be done).

Concretely speaking, if you have to create a URL like https://mysite.com?param%201=value%201& ... =value%202 you can do that with:

URL: https://mysite.com?param%201=value%201& ... =value%202

or with:

URL: https://mysite.com
Parameters: param 1=value 1
param 2=value 2
Thank you the suggestion I will look into that.

A bit of background what I'm doing here. I do have it working. The URL is built to pass into an email body for art upload but also posting the link via API to our project management site, this is similar to Monday.com, Smartsheets, etc. It was the last missing part.
Color Science & Workflow Automation
Post Reply