2

I have a visualforce page in which, on the page i have a button which redirects me to my Address Object Page generated by salesforce. The addresses have a bridge table in which i store the companies addresses so i can tell they belong to the company.

On my button click on my vf page how do i transfer a variable flag to my next page, which is a custom object page generated by salesforce. How would i be able to retrieve the variable.

So far i have seen how to transfer a variable to another page with getParameters. But is there anyway to retreive that info without a custom VF page. I wanted to make a custom button inside the page so that when it went to save it, it would know which it should store it to. But i am not sure if the variable would be able to reach the destination as it's nested in the first page.

Any help or direction would be great.

5
  • 1
    are you looking to save the value to that object? Is the page you are redirecting to have a field that you want populated by the previous page? Feb 6 '14 at 21:18
  • unfortunately no, the page i redirect to is the Custom Address Home Page, in which i cannot edit a single thing. The value won't be saved to the object it will only help indicate where the saving process should occur. I am trying my best to do workarounds from VF as my employer wants every page we create to look exactly like the standard pages available. I am kinda jammed up here.
    – user5619
    Feb 6 '14 at 21:23
  • 2
    Possible duplciate of How do I prepopulate fields on a Standard layout? Feb 6 '14 at 21:26
  • Can I redefine your question as "How do I use a query parameter (eg: myId in xxx.com?myId=test) in a standard salesforce page?"
    – BOSS_Force
    Feb 6 '14 at 21:48
  • Yeah i thought of a different solution in which i would set a varaible, pass the variable then use a trigger on insert. But the variable would be gone by the time i send it over to a standard controller for a custom object as it doesn't have custom variable definition. Instead I would need a variable that persists through pages. Looks like it is less feasible as i thought.
    – user5619
    Feb 7 '14 at 14:40
1

You can actually do this, but it requires some changes when you go between orgs. Go to the custom edit page for the page you want to naviage to inside of chrome (or another browser you are familiar debugging with) and right click the field and inspect element.

enter image description here

Grab the Id of the input and then before you navigate to the new page, put the Id as the key in the PageReference parameter and set the value to whatever you desire (EX: 00NC0000004wqLV=42). You will want to do that dynamically of course but keep in mind that you will need to do this to each different org you put the code in because the Id will likely change (unless its a Standard field).

Also, if you are trying to set a lookup field, then you need to grab the grab 2 Ids. 1 for the Name of the lookup and 1 for the Id of the lookup. It's a little more complicated but still similar.

If you just need the variable accessible to the page, you can name the URL parameter whatever you want and use a custom Javascript button in order to retrieve it.

0

Assuming I've understood correctly, what you are trying to do is pass a parameter on the URL to a custom object home page (i.e. the page that is displayed when you click on the tab for a custom object) and be able to use this parameter somewhere inside the page.

There is no way to do this that is supported I'm afraid. You could put some JavaScript into a sidebar textarea component to extract the parameter from the URL and update/inject a custom button on the tab page. This would be a fragile solution though and liable to break at any time if Salesforce do something to close down the effects of JavaScript in the sidebar.

If you are creating a custom list button to appear on the list views in the tab, you would be able to access the URL by defining the button behaviour to execute JavaScript and extracting the URL and parameters that way. E.g. button definition:

enter image description here

and result of clicking the JavaScript button:

enter image description here

of course this does assume that the additional behaviour you want from your button can be handled by JavaScript as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.