Hi,
Is there a way to replace spaces in folder names, in an url send in mail Body text?
Data:
file:///Volumes/Switch/[Job:UserFullName]/[Metadata.Text:Path="/field-list/field[1]/value",Dataset="Submit",Model="XML"]/[Job.Name]
Output
file:///Volumes/Switch/John A Smith/Folder 1 A/file1.pdf
Desired Output
file:///Volumes/Switch/John%20A%20Smith/Folder%201%20A/file1.pdf
Regards
Lars
URLencode Body text
Re: URLencode Body text
I don't know how to replace the spaces with %20, but I'd like to give you a tip regarding the metadata path.
If you want to increase readability and make it easier to know what metadata you're actually picking up, you can change the statement from:
[Metadata.Text:Path="/field-list/field[1]/value",Dataset="Submit",Model="XML"]
to
[Metadata.Text:Path="//field[tag='tag name']/value",Dataset="Submit",Model="XML"]
Where tag name is the metadata tag you're looking for. In you case it might be folderName, which would give you [Metadata.Text:Path="//field[tag='folderName']/value",Dataset="Submit",Model="XML"].
This is espescially helpful if you have a long metadata path. I've had paths like [Metadata.Text:Path="/field-list/field[1]/field-list/field[1]/field-list/field[2]/value",Dataset="Submit",Model="XML"] that I've been able to change to [Metadata.Text:Path="//field[tag='CSR E-mail']/value",Dataset="Submit",Model="XML"].
The tag name can be found in the metadata when you build your path in Switch.
If you want to increase readability and make it easier to know what metadata you're actually picking up, you can change the statement from:
[Metadata.Text:Path="/field-list/field[1]/value",Dataset="Submit",Model="XML"]
to
[Metadata.Text:Path="//field[tag='tag name']/value",Dataset="Submit",Model="XML"]
Where tag name is the metadata tag you're looking for. In you case it might be folderName, which would give you [Metadata.Text:Path="//field[tag='folderName']/value",Dataset="Submit",Model="XML"].
This is espescially helpful if you have a long metadata path. I've had paths like [Metadata.Text:Path="/field-list/field[1]/field-list/field[1]/field-list/field[2]/value",Dataset="Submit",Model="XML"] that I've been able to change to [Metadata.Text:Path="//field[tag='CSR E-mail']/value",Dataset="Submit",Model="XML"].
The tag name can be found in the metadata when you build your path in Switch.
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
-
- Member
- Posts: 121
- Joined: Wed Mar 22, 2017 5:05 pm
- Location: London, UK
- Contact:
Re: URLencode Body text
Hi
If you do rename and set it to search for Inline Value and it really is a space on the space bar.
Sort of like below (should be %20) it should work.
If you do rename and set it to search for Inline Value and it really is a space on the space bar.
Sort of like below (should be %20) it should work.
-
- Newbie
- Posts: 9
- Joined: Mon Mar 25, 2019 11:15 am
Re: URLencode Body text
Thanks Lasse,LasseThid wrote: ↑Mon Mar 25, 2019 6:27 pm If you want to increase readability and make it easier to know what metadata you're actually picking up, you can change the statement from:
[Metadata.Text:Path="/field-list/field[1]/value",Dataset="Submit",Model="XML"]
to
[Metadata.Text:Path="//field[tag='tag name']/value",Dataset="Submit",Model="XML"]
That's good advice.
-
- Newbie
- Posts: 9
- Joined: Mon Mar 25, 2019 11:15 am
Re: URLencode Body text
Hi Malcom,Malcolm Mackenzie wrote: ↑Mon Mar 25, 2019 6:39 pm Hi
If you do rename and set it to search for Inline Value and it really is a space on the space bar.
Sort of like below (should be %20) it should work.
Not sure that you can use Rename to modify metadata values?
-
- Member
- Posts: 121
- Joined: Wed Mar 22, 2017 5:05 pm
- Location: London, UK
- Contact:
Re: URLencode Body text
Hi Lars
My stupidity for not reading the issue correctly.
My stupidity for not reading the issue correctly.
Re: URLencode Body text
I haven't used Switch in a while -- so take this comment with a grain of salt.
The easiest (laziest?) way I can think of would be to remove any characters that need to be encoded. You could do that with a little regex or use a script like this (which will do that for you) https://github.com/open-automation/swit ... e-scrubber But if you are targeting a file on a volume then you would need to address the issue upstream from where you are referencing it.
But if you decide to write a script to do url encoding, maybe take a look at the script above which does a regex replace. You could tweak the same technique to replace the other characters or use the encodeURI method of the HTTP class https://www.enfocus.com/manuals/Develop ... class.html
The easiest (laziest?) way I can think of would be to remove any characters that need to be encoded. You could do that with a little regex or use a script like this (which will do that for you) https://github.com/open-automation/swit ... e-scrubber But if you are targeting a file on a volume then you would need to address the issue upstream from where you are referencing it.
But if you decide to write a script to do url encoding, maybe take a look at the script above which does a regex replace. You could tweak the same technique to replace the other characters or use the encodeURI method of the HTTP class https://www.enfocus.com/manuals/Develop ... class.html
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
-
- Newbie
- Posts: 9
- Joined: Mon Mar 25, 2019 11:15 am
Re: URLencode Body text
Thanks Gabriel,gabrielp wrote: ↑Tue Mar 26, 2019 8:50 pm ... or use a script like this (which will do that for you) https://github.com/open-automation/swit ... e-scrubber.
This looks like the right solution, but I will need the Scriting Module for this, right?
-
- Newbie
- Posts: 9
- Joined: Mon Mar 25, 2019 11:15 am
Re: URLencode Body text
Installed the Scriting Module trail, and Gabriel's solution worked great
Thanks again.
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Thanks again.