You need to sign in to do that
Don't have an account?
Andrew4
Pre-populating input fields on Visualforce page
Hi all,
I've been stuck on this for a while, so I'm finally asking for help - issue is similar to this one:
https://developer.salesforce.com/forums?id=906F000000094yFIAQ
I have a Visualforce page that uses the standard Event controller. I overrode the "New Event" button to direct to this Visualforce page. I'm having trouble pre-populating certain fields on that page.
For example, {!Event.whoID} is passed in the button URL and pre-populates the appropriate field by default. I want to pass the User ID too and populate the Assigned To field, but I can't get it to work. The default New Event page (which uses the same standard Event controller) populates the Assigned To field automatically, and without any additions in the URL... what am I missing? Does my VF page need a controller extension? If so, can anyone give pointers on what that needs to look like?
I assume I need to A) include whatever IDs I want populated in a custom button URL, and simultaneously B) build a controller extension that tells my VF page to pull the values out of the URL and load them in my input fields. But all my attempts to implement this setup so far have failed.
Any pointers will be greatly, greatly appreciated. Thanks for your help!
VF page snippet:
Current button URL (owner ID to be added):
Assuming a controller extension that looks something like:
Thanks again!
Andrew
I've been stuck on this for a while, so I'm finally asking for help - issue is similar to this one:
https://developer.salesforce.com/forums?id=906F000000094yFIAQ
I have a Visualforce page that uses the standard Event controller. I overrode the "New Event" button to direct to this Visualforce page. I'm having trouble pre-populating certain fields on that page.
For example, {!Event.whoID} is passed in the button URL and pre-populates the appropriate field by default. I want to pass the User ID too and populate the Assigned To field, but I can't get it to work. The default New Event page (which uses the same standard Event controller) populates the Assigned To field automatically, and without any additions in the URL... what am I missing? Does my VF page need a controller extension? If so, can anyone give pointers on what that needs to look like?
I assume I need to A) include whatever IDs I want populated in a custom button URL, and simultaneously B) build a controller extension that tells my VF page to pull the values out of the URL and load them in my input fields. But all my attempts to implement this setup so far have failed.
Any pointers will be greatly, greatly appreciated. Thanks for your help!
VF page snippet:
<apex:page standardController="Event" showHeader="true" sidebar="true"> <apex:sectionHeader title="Log A Call"/> <apex:form id="pageForm"> <apex:pageBlock title="Call Edit" mode="edit"> <apex:pageBlockButtons location="both"> <apex:commandButton value="Save" action="{!save}" id="saveButton"/> <apex:commandButton value="Cancel" action="{!cancel}" /> </apex:pageBlockButtons> <br /> <apex:pageBlockSection title="Owner" columns="2" collapsible="false"> <apex:inputField value="{!Event.ownerID}" label="Who took the call?" style="width:200px;height:15px;" /> <apex:inputField value="{!Event.StartDateTime}" label="Start" /> <apex:inputField value="{!Event.Subject}" label="Subject" /> <apex:inputField value="{!Event.EndDateTime}" label="End" /> <apex:inputField label="Person" value="{!Event.whoID}" style="width:300px;height:20px;" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Current button URL (owner ID to be added):
https://c.cs8.visual.force.com/apex/NewLogCall?who_id=XXXX&retURL=%XXXX&sfdc.override=1
Assuming a controller extension that looks something like:
public class callExtension { public callExtension(ApexPages.StandardController stdController){ public Event getEvent(){ if(event == null) event = new Event(); event.ownerid = ApexPages.currentPage().getParameters().get('ownerID'); return event; } } }
Thanks again!
Andrew
The custom button URL is as follows (OnClick JavaScript):
The controller extension is as follows:
For subsequent fields, simply add a new line in the controller extension, and add the value of the field into the button URL. Essentially the same solution as in the other thread on this topic, but this is code you can paste directly and get working. Thanks for everyone's help!
All Answers
Try with below code .Who id relationship with event is either lead or Contact .I have given one example with contact .
If your botton is in related list of contact then it will work .
Let me know if it helps .
Thanks
Manoj
Thanks so much for your help. I wrestled with your setup for a bit but I couldn't get it working - everything compiled but I simply couldn't get the values to populate.
I'm going to try out some of the techniques in this link and report what happens:
http://raydehler.com/cloud/clod/salesforce-url-hacking-to-prepopulate-fields-on-a-standard-page-layout.html
Thanks again. I'll keep you posted.
Could you please tell me one thing .
Where is your button ,in contact / lead relatedlist ?
If it is in contact related list then add one debug log to check the parentid varibale value .
If it is populating then above code should work .
Yes, the button is in the related lists, under Open Activities. I'm a bit new to this so I'll need to determine how to use the debug logs to confirm the parent id, but I'll follow up with you when I do.
Thanks again for your feedback! Much appreciated.
The custom button URL is as follows (OnClick JavaScript):
The controller extension is as follows:
For subsequent fields, simply add a new line in the controller extension, and add the value of the field into the button URL. Essentially the same solution as in the other thread on this topic, but this is code you can paste directly and get working. Thanks for everyone's help!
I have been following this article to do a very similar thing but for a task! I also cannot get the input fields to populate - although I am trying to set the parent of a parent field value on the task (child) record. Also, we are using person accounts, so acc and con share fields - super confusing to me. So I am not sure what I should be setting in the whoid... I am also an Apex newbie so apologies for the mistakes!
Extension:
Button:
VF Page:
When clicking the button I noticed that the url did not contain the whoid at all, where I thought it should?
Any help would be super appreciated!! :)