Creating a form to update a specific record

One of the great powers of forms is their ability to specify a specific existing record to update.  Contacts are easy to update, because any form that requires a login automatically knows the ID of the contact filling out the form.

But its also possible to have forms update a specific record of ANY object, by including a record ID in the URL that will open the form.  

To show how this can be done, let's create a form (and an email) that will allow a user to click on a link to a form, and update a specific volunteer opportunity:  In this example, we're going to be sending out an automated email to an Opportunity Coordinators asking them to respond to a survey related to one of their volunteer opportunities.  Here's how we get the form to update the correct Volunteer Opportunity.

 

1) Add the fields you wish to update to the object you will be updating.

In this case, we're adding a few 'survey' fields to the Volunteer Opportunity Record. We'll map these to the form we're creating.  We then create a form to update the Volunteer Opportunity object, and add fields to the form, mapped to the info we want to get updated when the respond to the survey request.

Be sure the form is set to sync data with Salesforce to the appropriate object, requires a login, and will update records.

If you want the name of the Volunteer Opportunity to show up in the record (for informational purposes), you can add a text field, mapped to "Volunteer Opportunity name" and set it as a 'read only' field.   (Mark this field as 'do not save to Salesforce" because you don't want the form to update the name that's already there.  We're just using the 'read only' function in the form field to display some existing information about the record.

2) At the bottom of the form Add a hidden field that will capture the ID of the record you wish to update

In order to map the answers to the correct Volunteer Opportunity, we add a hidden field which will pick up the ID from the URL we'll be sending out in an email template.  

The hidden field should have a default value of :  q:recid     (This means to bring in the ID portion of the URL that opens the form).

larry@handsonconnect.org (All Mail) — larry@handsonconnect.org (3 filtered messages)

Another good practice, but not required, is to also capture the ID of the contact that was logged in to complete the form.   (You don't have to map this to SF, but it will be captured and available via 'download form data' in the CMS if you ever wish to audit who actually submitted a form record on such and such date.

To do this, add a hidden field with the default value s:currentUserID

Other hidden field tokens you can use if desired are:

s:currentDateTime to set current Datetime or s:currentDateTimeOnSubmit to set the current datetime when the form is actually submitted.

larry@handsonconnect.org (All Mail) — larry@handsonconnect.org (3 filtered messages)

Save your Form:  and create a page to publish the form.  You'll need the page URL for the email you'll be sending out:  

larry@handsonconnect.org (All Mail) — larry@handsonconnect.org (3 filtered messages)

In this email template, we'll put whatever info we want and a URL that will take the user to the form, and put the record ID of the record we wish to have updated into the URL.   The merge fields in the email template should come from fields in the Volunteer Opportunity object (or whatever object your survey is going to update).     (Be sure to mention in the email that they will be required to be logged in in order to reach the linked form).

To construct the link to click on, your URL will include the following:

1. Get the merge field for the HOC_Domain_Name, for that record:  In this case it's  {!HOC__Volunteer_Opportunity__c.HOC__HOC_Domain_Name__c}

2. don't put in a slash (/) after this because the field HOC_Domain_Name includes the / in it.   This field is the URL that is associated with your public site:   For example: https://ps9015.handsonconnect.org/

3. Now put in the relative URL of the page the survey will be on.  In this case it's post-project-survey    (again, you don't need the / because its already in the HOC_Domain_Name which precedes it)

4.  Now add ?recid=   and then the merge field for the object's ID.    In this case this would be ?recid={!HOC__Volunteer_Opportunity__c.Id}

Your finished field (along with text to tell people to click on the link will look something like this:

larry@handsonconnect.org (All Mail) — larry@handsonconnect.org (3 filtered messages)

Select your entire merged URL, and then click on the hyperlink icon - and paste the full URL in.  This will ensure that the link is clickable and won't be 'broken' because it spans multiple lines in the email.

larry@handsonconnect.org (All Mail) — larry@handsonconnect.org (3 filtered messages)

Test your email template, by associating it with a specific Volunteer Opportunity record using the email templates "Send Test and Verify Merge Fields" functionality.  Be sure to associate it with a specific Volunteer Opportunity when conducting your test.

Test the email that is sent by clicking on the link and ensuring it successfully opens the form, and updates the corresponding record as expected.

4.  Create the Email Alert

Before you can send an email through Salesforce, you'll have to create an email alert that defines WHO to send the email to, and the "From" address.   You'll associate the email alert with this template you've just created.   IN this case, you'll probably want to send the email to the Opportunity Coordinator.

See this article on how to create an email alert.

5.  Create a Workflow or Process Builder to send your email

You'll now create a workflow, or preferably these days, a "Process" which defines the criteria for sending the email, and when to execute your email alert.  

If you're not familiar with creating processes using process builder, we recommend going through this Trailhead lesson for the basics of building processes.

0 Comments

Add your comment

E-Mail me when someone replies to this comment