I need to customize the contact page with some custom fields.
On the Contact page I want to include some custom fields which could be populated by a web service call using apex and while calling the page I should be able to pass the specific parameter to the apex code in order to call the webservice ?
In short I dont have value of this fields stored in the salesforce database I have some code(apex code that needs to be called for this). and get the value from a different system. whether it is possible and how ?
Any Help will be greatly appreciated
It is possible to embed visualforce pages onto page layouts. So I would recommend creating a visualforce page like the example below. Use the apex code you already have that is performing the webservice callout as the controller extension for this page and you'll be able to show the fields.
The only thing I'm unclear about is what specific parameter do you want to pass to your webservice? and how is it being passed to the contact page currently? If it's just a url parameter, your controller extension will have access to it using the ApexPages class. If it's the Id of the contact the constructor of the controller extension will be able to get it from the StandardController parameter.
Some important things to note:
the visualforce page must use the Contact standardController for it to be available as an embeddable visualforce page.
If the contact view action is already overridden the embedded visualforce page will not render. However if the page is already overridden you wouldn't have this problem because you could add the required code straight to the override page.
<apex:pageBlock id="block">
<apex:pageBlockSection id="section">
<apex:pageBlockSectionItem id="item">
<apex:outputLabel value="External Value:" for="externalValue" />
<apex:outputText id="externalValue" value="{!externalField}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
Related
Can we use method() from other apex classes into the VF page directly and by not using the controller of that VF page?
In Java, we can use package and do so, but I have no idea what to do with the apex and Vf page.
I would be thankful if anyone with the knowledge can help me out with this doubt.
Yes, you can use method() from another controller on your visualforce page, if method() is part of a global class.
See Apex Class Definition and When to use public, private, global
I created some pages with a hierarchy like Home(with child pages), About US, Contact How can I fetch the current page in lwc template?
Are there ways to fetch all the available pages in the community using the same template? Or is there any API object for the page name I can pass?
Thanks
I am trying to call an external api from salesforce apex class which will get all the products.so next i want to show these products as picklist in salesforce lead creation or edit page.I am not sure its possible or not.Any solution or workaround on these is mostly appreciated.
I don't see a way to do this on a standard layout.
I personnaly could do this in a Visualforce page. Probably you probably can do this in a Lightning page as well.
I am very new to Salesforce Apex. I created a simple Apex-Class to get all contacts in the salesforce website.
I used javascript code to invoke that class as follows
function runApex() {
sforce.interaction.runApex('AccountRetrieval', 'getAccount', 'name=Rajeev', callback);
}
It's working fine in my laptop. But how can my customers get to access that class to get all their contacts ?
If you can't simply give them access to the contacts tab in the UI to achieve what you're after then you can create a visualforce page with a custom controller. In the controller, use SOQL to run a query for all Contacts and save the result to a list or map. You can then use this variable to pass the Contact data to the visualforce page. If you just want to dump the data to the page as HTML then you can use a list variable to hold the query result and an apex:repeat tag to generate the HTML on the visualforce page. If you want more control over how the data is displayed then you could also use the apex variable to pass the data to a javascript variable which you could then build your HTML from client-side in whatever way you like.
More detail would be needed to give you full steps on how to set this all up exactly how you want but basically you should use a visualforce page to give them an interface to run your apex code from. Access to that page can be controlled via profiles or permission sets.
If this page needs to be visible to people who do not have a user account to log into your org then you can use the Salesforce feature called Sites to expose content to them without the need for a login.
I have a doubt, i've been working with salesforce for a while and now i have a requirement from a customer.
They need that some custom fields be populated with a value of parent object, making some research on stackoverflow, i found this post, but this isn't working for me because my project is a manage package and when this is installed on a another salesforce instance the id of custom field change.
if someone could help me, I will be grateful.
Thanks!.
I can't see any way of doing the same as that post without using the IDs, I was thinking you could route via a VF page and build up the URL in the controller but it doesn't seem as though you can get the IDs of fields, just their type etc..
I think the best you could do in this instance is to override the default new recordpage with a visualforce page. In the constructor of your controller you could then loop through the page parameters and pre-fill the corresponding fields on the new record before it's displayed on screen. Using fieldsets or just an <apex:Detail> component would keep the level of effort down and also maximise the flexibility of the page for the end users.