You are viewing limited content. For full access, please sign in.

Question

Question

Remove Ampersand & in the token values before passing as Values in URL

asked on March 23, 2015

How to remove ampersand & in the token values before passing as Values in URL

 

Token value SP-Type-Work : Cutting of concrete and making cores, breaking of concrete & removal of debris.

even i apply Encode URL and Encode XML functions in Email

https://Server.net/Forms/ABCD?entryid=%(Entry ID#@EncodeURI@#)&&type_of_work=%(RetrieveReview_SP-Type-of-Work#@EncodeURI;EncodeXML@#)

Resulting the blank form because of %20&amp as below

https://Server/Forms/ABCD?entryid=1556702&type_of_work=Cutting%20of%20concrete%20and%20making%20cores,%20breaking%20of%20concrete%20&%20removal%20of%20debris.

how to avoid it.

Regards

 

0 0

Replies

replied on March 25, 2015 Show version history

Adnan, sorry it took me so long to get back to you. It's been a busy week!

 

It seems that the EncodeUri token function is not as powerful as we'd hope. I put in a change request to add a slightly more powerful version of EncodeUri to the list of token functions. Hopefully the change will be in an upcoming version of WF soon.

 

In the meantime, we'll use a script. No worries, it's a very very simple script. I'll be very thorough about the steps so it'll look like a lot, but this is much more straightforward than it looks, since I'm just showing pictures of all the steps. Here are the steps:

1) Create a Script activity (not an SDK Script).

2) Select C# .NET as the Scripting Language

3) Double-click the script editor to edit your script. Paste the following code inside Execute() between the { and } directly below Execute:

            string escaped = System.Uri.EscapeDataString(this.GetTokenValue("TheNameOfYourToken").ToString());
            this.SetTokenValue("EscapedUrl", escaped);

Your script screen should look like something like this:

 

4) Now notice that it says "TheNameOfYourToken" in red. Replace this with the name of your actual token, without the %(). For example, if you have a token like %(RetrieveFieldValues_TheUrlFieldName), then the code above should end up looking like this:

 

5) Now we'll create a token from our newly escaped token. At the bottom of the editor, notice click the Script Tokens tab, as pictured and indicated:

 

6) In the newly opened tab, click this button (AutoDetect Tokens):

If that worked, you should see the EscapedUrl item appear, as pictured above. If that does not appear, then you can manually enter that name under the Name column. This name must match the token in red in your script, which under my script is called "EscapedUrl" (though you can call it whatever you'd like). This is the token that contains the escaped value you will have wanted.

7) Save your script on the top left and close the script editor.

8) You can use your token just like any other token. The source activity will be your Script activity:

In this case, my Script activity is just called "Script". 

 

Let me know if this works for you =).

 

 

2 0
replied on March 23, 2015

Adnan, try removing the Encode XML function, as it does not apply to the URL case. Furthermore, it's the Encode XML function that causes the &amp after encoding (which is a standard for encoding & in XML, though not in URLs)

1 0
replied on March 23, 2015

Dear Flavio,

Problem still there after removing Encode XML, cause i wanted to remove any & from the string before passing to URL as parameter.

 

0 0
replied on December 14, 2021

I am trying to achieve the same thing in Forms on a custom html field. Any suggestions on how to pass the ampersand without throwing off passing the variables?

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.