You need to sign in to do that
Don't have an account?
VarunC
Passing values as parameters in URL visualforce page
Hi I'm not able to pass a Field Value in URL to another page so that a Particular field is always prepopulated on page load.
I've my button code as this:
With this URL the value is Set correctly, but the value is not prefiled on page load :(.
Now if I replace the value of URL to this:
Where 00N80000002c4Qe is ID value of the control on target page which is needed to be pre-populated. But this above throws me SYNTAX Error of missing Field Name.
Can anyone guide me how to properly Set Return URL as well as pass some custom values in URL from a VF page?
I've my button code as this:
Code:
<apex:commandButton value="New Billing" onclick="javascript:{!URLFOR($Action.Billing__c.New,null,[retURL=URLFOR($Action.Task.View,task.Id),ActivityId__c=task.Id],false)}"/>
Now if I replace the value of URL to this:
Code:
<apex:commandButton value="New Billing" onclick="javascript:{!URLFOR($Action.Billing__c.New,null,[retURL=URLFOR($Action.Task.View,task.Id),00N80000002c4Qe=task.Id],false)}"/>
Where 00N80000002c4Qe is ID value of the control on target page which is needed to be pre-populated. But this above throws me SYNTAX Error of missing Field Name.
Can anyone guide me how to properly Set Return URL as well as pass some custom values in URL from a VF page?
Here's some workaround code that you could modify if you don't want to hard code the field Ids:
Visualforce Page
<apex:page standardController="Contact" extensions="logMeetingExtension" action="{!createMeetingAndRedirect}"/>
Controller Extension
public class logMeetingExtension {
Contact contact;
public logMeetingExtension(ApexPages.StandardController controller) {
contact = (Contact)controller.getRecord();
}
public PageReference createMeetingAndRedirect() {
Event e = new Event(Subject = 'some subject');
e.DurationInMinutes = 60;
e.ActivityDateTime = System.now();
//fill in all the fields you like here
// ...
insert e;
return ApexPages.StandardController(e).edit();
}
}
This solution does have the drawback of creating a new record even if the user navigates away from the page before clicking on the "Save" button though...
All Answers
You can get the field name by viewing the source of the edit page and seeing the id/name of the input.
I have found the same problem with trying to pass values to custom fields inside the [] brackets. The following works for me:
<script type="text/javascript">
window.parent.location.href="{!URLFOR($Action.Activity.NewEvent,null,
[retURL=URLFOR( $Action.Contact.View, Contact.Id)]
)} &00N80000002rqFh=Here&RecordType=01280000000EpvV&type=Event&setupid=EventRecords";
</script>
Mark
Here's some workaround code that you could modify if you don't want to hard code the field Ids:
Visualforce Page
<apex:page standardController="Contact" extensions="logMeetingExtension" action="{!createMeetingAndRedirect}"/>
Controller Extension
public class logMeetingExtension {
Contact contact;
public logMeetingExtension(ApexPages.StandardController controller) {
contact = (Contact)controller.getRecord();
}
public PageReference createMeetingAndRedirect() {
Event e = new Event(Subject = 'some subject');
e.DurationInMinutes = 60;
e.ActivityDateTime = System.now();
//fill in all the fields you like here
// ...
insert e;
return ApexPages.StandardController(e).edit();
}
}
This solution does have the drawback of creating a new record even if the user navigates away from the page before clicking on the "Save" button though...
You can look at the solution outlined in this series of posts.