0

Here's what I am trying to do:
1) User creates record A.
2) Time-based workflow sends an email to the Record A creator based on a date field in the record.
3) The email template has a URL link.
4) The URL links to a Visualforce page that is basically a form with fields to be filled out (this Visualforce page is in a managed package) and a save button that creates a new User record.
5) When the User clicks the URL link in the email, the Visualforce page opens in a new window.
6) I would like to pass the values of the fields in record A to pre-fill the Visualforce page fields.

Here's my link:

<a href="https://cs19.visual.force.com/apex/CloneThisUser?Desktop=true&Id={!Pending_User__c.User_to_CloneId__c}&formGroupInputSmall={!Pending_User__c.First_Name__c}

And here's the code from the relevant section of the Visualforce page:

<div class="form-group form-group-sm">
      <!-- <apex:outputLabel styleClass="col-sm-2 control-label" for="formGroupInputSmall">First Name</apex:outputLabel> -->
      <div class="col-xm-11 col-sm-12">
          <apex:inputField html-placeholder="First Name" styleClass="form-control FirstNameInput"  value="{!u.FirstName}" id="formGroupInputSmall"/>
      </div>
    </div>

I have only included the first field I would like to pass the parameter to, in order to keep this post simple.

The link passes the User_to_Clone_Id__c just fine but does not fill in the "First Name" field with the value of the First_Name__c .

What am I doing incorrectly? Thanks.

  • Appreciate the first two answers below, but I can't modify the Visualforce page or its controller as they are both part of a managed package. – GSquared Sep 7 '16 at 12:49
  • You may be able to wrap your managed package's page in an apex:include on your own custom page, but I haven't worked with managed packages before. – IllusiveBrian Sep 8 '16 at 23:19
1

Do you need all of the parameters or can you simply pass the ID of the record A containing the values?

I would change my link to pass in the ID of the Record A

?dataid={recorded}

Then I would use a controller for the VF page that in its constructor would query for the Record A record from the URL param and populate the values of u.FirstName etc.

If the value are populated in the controller when the page loads it will be prepopulated as desired.

If you are concerned about the ID being exposed, use AES encryption to encrypt the ID and put it in the email template (May need a field populated by a trigger to store it to use in the email). Then decrypt it in the controller

| improve this answer | |
-1

To retrieve page parameters on the Visualforce page, use $CurrentPage.parameters.paramName. However, it does not seem like apex:inputField has a way of specifying a default value other than the field. One option is to assign a default value using javascript:

<apex:inputField html-placeholder="First Name" styleClass="form-control FirstNameInput"  value="{!u.FirstName}" id="formGroupInputSmall"/>
<script>
    document.getElementById('$Component.formGroupInputSmall').value = '$currentPage.parameters.formGroupInputSmall';
</script>
| improve this answer | |

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.