Idan Bliech
Nov 7 · 1 min read

A client came to me mention a Visualforce page not working in Production, telling me it worked fine in Sandbox.

Issue

First look in the Visualforce page was enough to locate the issue, the WebToCase action was hardcoded in the html, like this :

action="https://llib--dev1.cs80.my.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8"

So the cases were created in some old not even valid sandbox.

Solution

I replace the URL with some more dynamically formula:

** in some cases where myDomain contains hyphens you will need to change the formula

{!SUBSTITUTE(SUBSTITUTE($Site.Domain, "-", "--"), "force.com", "my.salesforce.com")}

So now the action attribute look like this :

action=”https://{!SUBSTITUTE(SUBSTITUTE($Site.Domain, “-”, “ — “), “force.com”, “my.salesforce.com”)}/servlet/servlet.WebToCase?encoding=UTF-8"

Testing..

and it’s working :)


Idan Bliech

Written by

Salesforce Technical Architect ⚙️ Israel User Group Leader ⚙️ Soon on the AppExchange sbxmanager.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade