1

I have an visualforce page with logic (VF page), which have a textfield (Text1). On load, the textfield is populated with a value from a parameter from the URL which is used for loading the VF Page. Below the Text1 field the VF Page is using the standard controller for Contact, with an extension. It shows the contact with all related fields/lists. Including relatedlist cases. Let's call the URL to this page:

salesforce/pages/tel?Id=12132&name=allen

As mentioned this VF Page uses standard controller to show complete contact details, and when the user clicks "New Case" button in relatedlist cases, I would like to transfer a variable from the VF Page, to a case field on the new case detail screen which opens.

So I want to transfer a variable from one context to another.

Is this possible? And how?

https://something.my.salesforce.com/500/e?cas14=Hello&cas15=World&cas3="{!$ApexPages.currentPage().getParameters().get('JobNo')}"

I want to use the parameters from the first URL im opening, to be used in the URL which is opened when i click custom "New Case" button. But how can I access the URL parameters to use in the forumla field for a custom button?

If I somehow could read the URL which I left, when i clicked the custom button, then I could substring the URL to only include the Parameter which i need, but I can't seem to find any method for retrieving this complete URL.

1 Answer 1

1

The standard new Case page has some fixed field names and values can be passed into the page using those names. To see this working enter this URL:

/500/e?cas14=Hello&cas15=World

You can find the names by using your browser's "Inspect Element" on each of the input fields.

However, these names and this mechanism are not part of the platform's API and so may stop working in the future - this is a hack. (The platform moving to use Lightning components may mean changes that break this sort of hack will be coming quite soon.) Unfortunately AFAIK there is no supported API alternative.

7
  • I can see it works fint, but how can I Refer to a field on the Custom VF Page, the field where the value is? Jun 8, 2015 at 10:37
  • $CurrentPage.parameters.Param1 - This doesn't see mto work. Jun 8, 2015 at 10:42
  • While you could grab the values using JavaScript, its probably easiest to make your "New Case" button an apex:commandButton and add the parameters using a PageReference.
    – Keith C
    Jun 8, 2015 at 10:51
  • But would I then be able to show the new button in the related list "Cases" on Contact? I added my Custom Button URL (Syntax Error): Jun 8, 2015 at 11:30
  • How can I read the parameter from the URL I'm coming from? I mean, im on a VF Page (With URL parameters loaded), and click on Custom New Case button. How can i then set a field to one of the parameters from the URL which I came from? Jun 9, 2015 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .