This guide will cover:

Similar documents
Document revision 1.0

Visualforce Developer's Guide

Salesforce DEV-501. Apex and Visualforce Controllers (DEV501)

Visualforce Workbook

Visualforce Developer's Guide

Visualforce Developer's Guide

Service SDK Developer s Guide for ios

Service SDK Developer s Guide for ios PREVIEW

Force.com Streaming API Developer Guide

LinkedIn Sales Navigator for Salesforce Installation Guide: Lightning View

Introduction Setup Install package Amazon S3 sign up Add remote site Connect to Amazon S Create S3 bucket...

SkyVisualEditor VisualforcePage Import User Manual

Live Agent Developer Guide

Visualforce & Lightning Experience

Installation & Configuration Guide Enterprise/Unlimited Edition

RingCentral Call Center for Salesforce. Administrator Guide

Convert Your JavaScript Buttons for Lightning Experience

Quick Actions Implementation Guide

Quick Actions Implementation Guide

Velocify Admin The Velocify Admin tab has been re-designed to provide a much better user experience, focusing on selfservice

Visual Workflow Implementation Guide

Capture Installation and Guide

License Management and Support Guide

Oracle Eloqua Profiler

Siteforce Pilot: Best Practices

TRAINING & CERTIFICATION. Salesforce.com Certified Force.com Developer Study Guide

Quick Actions Implementation Guide

READSPEAKER BLACKBOARD BUILDING BLOCK

Salesforce.com Winter 18 Release

Hello, welcome to this brief tutorial on accessing and playing Adobe Presenter video files.

MassMailer Configuration Guide

SkyVisualEditor Salesforce1 Support Guide

icontact for Salesforce Crash Course Mastering the Fundamentals Salesforce Lightning

Help Documentation. Copyright 2007 WebAssist.com Corporation All rights reserved.

RingCentral for Salesforce Classic. UK Administrator Guide

Administrator Guide. v Decisions on Demand, Inc. - All Rights Reserved

The Design Environment

Enhance Salesforce with Code

Service SDK Developer s Guide for Android

RingCentral for Salesforce. Administrator Guide

ServiceMax Basic Navigation

Force.com Sites Implementation Guide

BT Web Hosting. Features and functionality

Quick Actions Implementation Guide

S-Drive Installation Guide v1.28

Connecture Platform Manager

Organizing Your Network with Netvibes 2009

Live Agent Developer's Guide

S-Drive Salesforce Mobile App Configuration And User Guide v2.1

DocVerify E-Signature Salesforce Application How to Create a New E-Signature Document. Versions 4.0 and above.

GETTING STARTED WITH SETTING UP CALL CENTERS

GETTING STARTED WITH SETTING UP CALL CENTERS

Salesforce Admin & Development Training

ebook Writing Workshop Practical 1: A First Logfile-Style ebook

FrontPage Help Center. Topic: FrontPage Basics

icontact for Salesforce Installation Guide

TeamViewer 12 Manual Management Console. Rev

AGENDA. DEX450: Programmatic Development Using Apex and Visualforce. Day One

QuickStart Guide 6 - Data Quality

AT&T Bolt-On Ordering & Sales Tool BOOST (Indirect)

Install Guide WINTER '15 REVISION C. C o p y r i g h t C l o u d A p p s L t d

Whitehat Copycat Awebwer BluePrint. Tim Bekker introducing Copycat Sites...

Snap-Ins for Web Developer Guide

How to Integrate Salesforce with Your Constant Contact Account FOR PROFESSIONAL & GROUP EDITIONS

Manage Workflows. Workflows and Workflow Actions

Release Notes October 2016

Force.com Sites Implementation Guide

Software Registration Instructions

How to ZAP Realtor.com Leads into Realvolve

New website Training:

CUSTOMER PORTAL. Custom HTML splashpage Guide

PlayerLync Forms User Guide (MachForm)

Force.com Mobile Web with Sencha Touch

If you encounter any problems with this please contact us at

Setting PSE 15 Preferences

Brief Intro to Firebug Sukwon Oh CSC309, Summer 2015

Payment Pages Customisation Version 2

Refreshing the Dashboard allows you to make sure you are seeing the most recent data in your visualizations.

Creating a Presentation

QuickStart Guide 2 - Normalisation

Perceptive Interact for Salesforce Enterprise

TUTORIAL HOW TO: - Edit an Template with Constant Contact Create an

OU Mashup V2. Display Page

MIGRATING FROM PORTALS TO COMMUNITIES

Cloud Flow Designer Guide PREVIEW

Streaming API Developer Guide

Filtering - Zimbra

Oracle CPQ Cloud for Salesforce.com

ACCESS GENERAL QUERIES TECHNICAL ISSUES WITH SPECIFIC COURSES. What do I do if I see Invalid log-in? How do I Access the LMS?

goalgamipro Salesforce App

No Programming Required Create web apps rapidly with Web AppBuilder for ArcGIS

Adding Disclaimer Text Field to your Salesforce Org

Salesforce Classic Mobile Guide for iphone

Creating Secure Force.com Applications Access Control in Force.com

Horizon Integrator CRM. Salpo Add-in Guide

Perceptive Interact for Salesforce Enterprise

Snapshot Best Practices: Continuous Integration

FrontPage 2003 Lesson 4 - Creating Individual Pages. Adding a Page Using a Template. Web Page Title. Saving a Web Page

Customer Support Guide. How to insert a photo into a tile in WX

HTML5 Creatives. MediaMath now supports HTML5 Creatives. Each T1AS HTML5 Creative must be uploaded with the following 2 components:

Transcription:

This guide will cover: Adding the essential code to the VisualForce page Setting up the address fields Adding the fields to the AddressTools setup Creating an AddressTools trigger for the VisualForce page An example VisualForce page Note: This guide assumes you are familiar with VisualForce and are using the Premium version of AddressTools, if you are not using Premium and are interested in finding out more, you can trial it for free at http://sforce.co/1dfeowp. 1. The following statements need to be added at the top of your VisualForce page just inside the apex:page tag. <apex:includescript value="/soap/ajax/27.0/connection.js" /> <apex:includescript value="/soap/ajax/27.0/apex.js" /> <apex:includescript value="/apex/pw_ccpro CountriesJavaScript?core.apexpages.devmode.url=1" /> <apex:includescript value="{!urlfor($resource.pw_ccpro CountryCompleteResources, '/javascript/countryautocomplete.js')}" /> <apex:includescript value="{!urlfor($resource.pw_ccpro AddressCompleteResources, '/javascript/addresscomplete.js')}" /> You must now choose one of following two approaches to execute the AddressTools Javascript on your VisualForce page. Option A) Add a new <script> block to your code as follows: <script type="text/javascript"> sforce.connection.sessionid = '{!$Api.Session_ID}'; </script>

Option B) Add the same statement to the page's existing document.onload() function: <script type="text/javascript"> // Other JS here window.document.onload = new function(e) { // Other initialisation here sforce.connection.sessionid = '{!$Api.Session_ID}'; // Other initialisation here } </script> If your VisualForce page consists of any Apex or Salesforce Operations such as showing/hiding fields, you will need to paste the following code into your VisualForce page after the operation is called which will re-initialise the tool. function OnComplete() { preinit(); preinitcc(); ProvenWorks.AutoComplete.Init(); ProvenWorks.AddressComplete.Init(); ProvenWorks.ZipCodeLookup.enforceValidation('zipcodeID ); } Note: the zipcodeid text highlighted above must be changed to the zipcode ID you have used on your Address field. The IDs are explained in the next step. The address fields must follow two rules: 1) The fields must be linked to a pre-existent field in a Salesforce object, see the snippet of code below which shows the county field linked to the Custom Object, NewObject c which has a custom country field by the name of Country c. This section is in bold in the snippet below. <apex:inputfield id="countryid" value="{!newobject c.country c}" /> 2) Each field must have a unique ID, we use IDs to reference the fields so that AddressTools knows where to add functionality. Notice that id= is added to the apex:inputfield tag to achieve this. <apex:inputfield id="countryid" value="{!newobject c.country c}" /> Page 2 of 9

A completed address field in VisualForce may look similar to the example below: <apex:form> <apex:inputfield id="streetid" value="{!newobject c.billing_street c}"/> <apex:inputfield id="cityid" value="{!newobject c.city c}" /> <apex:inputfield id="stateid" value="{!newobject c.state c}" /> <apex:inputfield id="zipid" value="{!newobject c.zip c}" /> <apex:inputfield id="countryid" value="{!newobject c.country c}" /> <apex:inputfield id="lonid" value="{!newobject c.lon c}" /> <apex:inputfield id="latid" value="{!newobject c.lat c}" /> </apex:form> Now that we have configured the address field, we can continue onto adding the fields and IDs to the AddressTools Settings. 1) Navigate to AddressTools Administration Tab and select the Settings sub-tab. 2) Locate the Fields to Validate/Standardize section and select Add. Page 3 of 9

3) Find the Object that the fields are located on, this will be the same object that we referenced in the last step. {!NewObject c.billing_street c} and choose the appropriate fields from the dropdowns provided on the page. 4) Select the + next to Field ID #1 to display the fields where you can input your field IDs. 5) Take the IDs that we assigned each field in the VisualForce page and place them into the correct ID field in the Field Mappings section. Page 4 of 9

6) Before saving the fields, check the options at the bottom of the page to enable settings such as Country Mandatory or Support Street-Level Validation. 7) Press Add & Save. After successfully linking the fields to AddressTools, we want to create a trigger so that the information gets standardized on save and checks whether all requirements are met. 1) Goto Setup in the top-right corner of your Salesforce environment. 2a) If the object is a standard object, navigate to Build Customize Object Name Triggers 2b) If the object is a custom object, navigate to Build Create Objects Object Name then locate the section Triggers. Page 5 of 9

3) Select New. 4) You will now be met with a text area to write your trigger, delete what it automatically generated in the field and paste the code below into the trigger s code field, note that the example below is for the NewObject object. Replace the highlighted text to the object s API name. Be sure to remove the c from the first instance if it is a custom object to avoid Invalid identifier errors. trigger ValidateNewObjectCountryFields on NewObject c (before insert, before update) { pw_ccpro.countryvalidator2.validate(trigger.new, Trigger.oldMap); } 5) Press Save. Once saved, your view will now look some like this and the trigger will have now been successfully created. Page 6 of 9

You will now have all the required information on how to implement AddressTools functionality on your Salesforce VisualForce page. Below is an example of what your VisualForce page s code may look like and a visual of the front end result. <apex:page standardcontroller="newobject c"> <apex:includescript value="/soap/ajax/27.0/connection.js" /> <apex:includescript value="/soap/ajax/27.0/apex.js" /> <apex:includescript value="/apex/pw_ccpro CountriesJavaScript?core.apexpages.devmode.url=1" /> <apex:includescript value="{!urlfor($resource.pw_ccpro CountryCompleteResources, '/javascript/countryautocomplete.js')}" /> <apex:includescript value="{!urlfor($resource.pw_ccpro AddressCompleteResources, '/javascript/addresscomplete.js')}" /> <script type="text/javascript"> sforce.connection.sessionid = '{!$Api.Session_ID}'; </script> <p> <apex:pagemessages id="msg" /> </p> <apex:form > <apex:pageblock > <apex:pageblocksection columns="1"> <apex:inputfield id="streetid" value="{!newobject c.billing_street c}"/> <apex:inputfield id="cityid" value="{!newobject c.city c}" /> <apex:inputfield id="stateid" value="{!newobject c.state c}" /> <apex:inputfield id="zipid" value="{!newobject c.zip c}" /> <apex:inputfield id="countryid" value="{!newobject c.country c}" /> <apex:inputfield id="lonid" value="{!newobject c.lon c}" /> <apex:inputfield id="latid" value="{!newobject c.lat c}" /> </apex:pageblocksection> </apex:pageblock> </apex:form> </apex:page> When going to test the VisualForce page above, you will be met with a display similar to the one here. You can test its functionality by beginning to type a country and seeing that a dropdown appears. Page 7 of 9

Note: All of these questions are in relation to the example above with the Custom Object being named NewObject and all of the address fields going by the names from above, please read through the questions and acknowledge that the custom objects and fields may be of a different name to yours. Q) When I try to save my new VisualForce page, I am receiving the error the following error: Error: Unknown property 'NewObject c' referenced in NewObject A) You must add the object you are using as a standardcontroller tag to the first <apex:page> so it would appear like this: <apex:page standardcontroller= NewObject c > Q) When I try to save my new VisualForce page, I am receiving the error the following error: Error: NewObject c does not exist A) Ensure that you have an object in your Org by the name of NewObject Q) When I try to save my new VisualForce page, I am receiving the error the following error: Error: Could not resolve field 'Billing_Street c' from <apex:inputfield> value binding '{!NewObject c.billing_street c}' in page NewObject. A) You must ensure that there is a field created in your Object by the name of Billing Street. Q) When I preview my VisualForce page, it looks something like this: A) The tutorial we provide is for a very quick and simple VisualForce page, if you add <apex:pageblock > <apex:pageblocksection columns="1"> Just after the form tag and matching closing tags for these just before the closing form tag, the layout should then match the one shown in the final example. Page 8 of 9

Q) When I try to save my trigger, I am met with the following error: Error: Compile Error: Invalid identifier: ValidateNewObject ccountryfields at line 1 column 9 A) Making sure you remove the c from the trigger name as this will cause the trigger to be classed as an Invalid identifier. Q) I went to test my VisualForce page and the dropdown list isn t appearing when I begin to type a state or country. A) Make sure you clear your browser s cache and reload the page. Most browser s cache can be cleared by pressing [Ctrl+Shift+Del] If you are still unable to successfully place AddressTools functionality on your VisualForce page, please feel free to get in contact with us at: support@provenworks.com Page 9 of 9