Really new to VF, but here's my VF page. the desired effect is that i want it opened up in a new tab in the same window.
<apex:page standardController="myController__c" extensions="myExtension" action=" {!actionJackson}">
</apex:page>
If your overriding a standard VF page in SFDC your halfway there, it looks like your trying to reference a standard controller of a custom sObject called: 'myController__c', kind of a weird name for an object but if you want to import the standard controller use your objects name as the standardController.
If your custom sObject that you were trying to create a new VF page for was called: "myObject__c" than your page definition would look like:
<apex:page standardcontroller="myobject__c" extensions="class1"></apex:page>
Now go (using the web-ui):
Your Name->Setup->Create->Objects->myObject__c->Standard Buttons and Links->Edit 'View' (lets say you wanted to replace the 'View')
Now choose to override with a VisualForce Page and select the name of your page from the drop down.
Now following the link to view a record in SFDC standard layouts will take you to the new custom vf page. The same goes for edit (if you override it).
Now all you have to do is follow the instructions on SFDC for using and extending the standard controller or standard list controller.
Related
I have two vf pages, say vf1 and vf2, which have standard controller for same object say Leads. Now i want to show vf1 page for edit button for any profile1 and and vf2 page for profile2 on edit button.
Tried to see any option in Profile menu, but not able to find anything for page assignment for list/edit/create/...etc. for an object.
There is no such feature in Salesforce to allow visualforce page assignment per profile.
I would recommend below
1.Create a hirerachy custom setting to store the mapping between the vf page and the profile .
2.Write a vf that will be assigned for all profiles but on action (called upon where page loads) it will look into the hirerachy custom settings map and takes the user to right visualforce page .You can pass along page parameters as query parameters .
How can I put custom links outside the web links section in a salesforce page?
Or is there a way I can create more than one weblinks section?
If not is there a way I can create a custom field that can call a javascript method ? (my custom links calls a js method that after validation will call a web service to do some work.)
I tried creating a custom field (formula) but I wasnt able to call a js function from there, or put some script.
What I want to do is spread my custom links I have in the weblinks section into different sections on the page.
I have used this method to override link and button actions in the past. You could use the same method for move elements around the page too.
Create a visualforce page and use it to override the standard page for the object you want to modify. The override page needs to use the standardcontroller for that object. You can use an extension controller for adding Apex functionality if necessary.
Use the detail tag to render the guts. Then put in a script tag to select the anchor links you want to move around the page. It will take some inspection with your browsers debugger to find exactly what you are looking for.
<apex:page StandardController="CustomObject__c" extensions="CustomObjectController" >
<apex:detail relatedList="false" inlineEdit="true" id="mydetail" />
<script>
// select your elements you want to move, edit or delete here
</script>
</apex:page>
I have a Visualforce page using a custom controller that is used to edit multiple records under an opportunity.
I'd like to create a custom button or link from Opportunities to this Visualforce page.
Currently the link looks like:
/apex/ExamplePage?oppId={!Opportunity.Id}
This works fine in the development sandbox, but when it is deployed as part of a managed package the link breaks as the page reference doesn't have the namespace prefix.
I found the post Managed Package Redirecting Problem on the Force.com Discussion Boards which implied it should be possible to use $Page to reference the Visualforce page in the URL. E.g.
{!URLFOR($Page.MyExamplePage,'',[objectId = campaign.id])}
But doing so only gives me the syntax error:
Error: Field $Page.MyExamplePage does not exist. Check spelling.
There is another part to the post that suggests using an Apex class and Execute Javascript to work around it. But it appears to me that this has just moved the namespace issue into the Javascript.
How can I safely reference the Visualforce page to work both inside and outside a managed package?
Best to do this from an Apex PageReference return value. Something like this will work:
public PageReference returnPage()
{
return Page.MyExamplePage;
}
Then call this from Visualforce:
<apex:commandButton value="Go To New Page" action="{!returnPage}"/>
The Apex Page call will handle the translation for you.
[EDIT]
Create a bare bones Visualforce page like this:
<apex:page standardController="Opportunity" extensions="TheController" action="{!returnPage}"/>
Add the above returnPage() method to a new TheController (or whatever) class. It doesn't even need a constructor. The class can look like this:
public TheController
{
public PageReference returnPage()
{
return Page.MyExamplePage;
}
}
Then from the Opportunity settings page go to Buttons and Links and create a new custom Visualforce button selecting the new page you just created.
That should do it.
It occurred to me that one less than ideal option would be to create two custom buttons in each case. One with the managed package namespace and one without.
When building the package the correct custom button could be selected.
One issue with this approach is the need to maintain two custom buttons.
It seems the answer is simply /apex/package__Page as provided here by #zachelrath. I can confirm this works in managed packages in production orgs as well as in development.
The post on the developer boards that you've linked to shows the following javascript being used for the button:
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var pageUrl = sforce.apex.execute("mynamespace.PageUrl", "getPageUrl", {objectId:"{!Campaign.Id}"});
window.location.href = pageUrl;
i.e. they're using javascript to call a webservice method in the class they've defined in order to get the page reference. Doing this would allow you to get the URL of the page in apex, where the managed package won't play an impacting part.
That said, the first parameter is the fully-qualified class name, so you could probably check the return value for an error (I don't know the error return value, so I'm assuming it's null here):
// try the namespace first
var pageUrl = sforce.apex.execute("mynamespace.myClass", "getPageUrl", {objectId:"{!Campaign.Id}"});
if (pageUrl == null)
{
pageUrl = sforce.apex.execute("myClass", "getPageUrl", {objectId:"{!Campaign.Id}"});
}
window.location.href = pageUrl;
Obviously you need to check what happens when sforce.apex.execute() fails, and you'll likely want some more error handling.
I have visualforce page CompetitorSearch.page that use CompSearchDummy__c as standard controller.
<apex:page StandardController="CompSearchDummy__c" extensions="CompetitorSearch">
If I am to add custom button on the page of CompSearchDummy, CompetitorSearch.page shows up for the page destination.
But I have Talent page which use Talent__c sObject and when I tried to add custom button and attempt to set destination, CompetitorSearch.page does not show up as an option because I did not set Talent__c as standard controller.
Is it possible to somehow add my CompetitorSearch.page link to Talent page?
If I understand your question correctly, you want to add an apex:commandButton to go to another page. When you were on the same page, it was just refreshing itself, but to go to another page, you need to specify an action in the apex:commandButton that points to a method in a controller extension that returns a PageReference for where you want to go. Like this:
<apex:commandButton action="{!gotoCompetitorSearch}" value="Competitor Search" />
public PageReference gotoCompetitorSearch() {
return Page.CompetitorSearch;
}
Note, if you don't really need a button or special logic and just want to go to another page, you can do this with just an apex:outputLink with no need for a controller extension, like this:
<apex:outputLink value="{!$Page.CompetitorSearch}">CompetitorSearch</apex:outputLink>
I'm writing a VisualForce page to replace an old legacy S-Control.
Originally the Custom S-Control was launched from a Custom Button, and it opened in a new browser window (The S-Control is type HTML, and the Custom Button has Behavior: Display in new window)
For certain old records, I want to do a similar thing from VisualForce.
So: Do HTML S-Controls have a URL that I can launch using a link? In which case, how do I figure out the URL?
Or:
Is there a way of embedding 'Custom Buttons' (that is, the buttons defined in "Setup->Customise->Account->Buttons and Links") into VisualForce pages? If so, I can embed the existing button that knows how to open the S-Control
Or:
Can you suggest some other way of doing this? Key features: Open an S-Control in a new window from VisualForce.
Thanks
Got an answer from this forum post courtesy of aballard:
Basically, the !Urlfor() function can be used to get the URL of an S-Control. So, you can use an outputLink like this:
<apex:outputLink value="{!UrlFor($SControl.my_scontrol_name)}"
target="_blank">Show SControl</apex:outputLink>
If you need to pass an object ID to the S-Control, you can add a second parameter that calls a propery on the custom controller, e.g:
<apex:outputLink value="{!UrlFor($SControl.my_scontrol_name, AccountID)}"
target="_blank">Show SControl</apex:outputLink>
... where AccountID is defined on the custom controller as public string getAccountID()
See also this blog post at SalesforceSource for more info on the UrlFor function.