Salesforce uses Open Authorization to connect to your Salesforce account. This process enables you to connect your WordPress site to Salesforce without having to store your Salesforce username and password in the website. You will create a “Connected App” in Salesforce, which has its own Consumer Key and Consumer Secret. This ID and Secret is what you will enter into WordPress to help you gain access to your Salesforce account.
Creating Your Connected App
Please note, if you have trouble creating your Connected App, you may need to talk to your Salesforce account support help, as Ninja Forms cannot provide detailed support for Salesforce accounts. These steps, however, should help you get quickly started:
- Log into your Salesforce account.
- Click “Setup” “Connected Apps” “New”.
New Connected App Settings
- Choose a Connected App name; Salesforce will generate an API name for you based on your chosen name
- Provide a contact email address.
- Select “Enable OAuth Settings”.
- Callback URL must be: https://login.salesforce.com/services/oauth2/success
- Chose the following two scopes:
- Access and manage your data (api).
- Perform requests on your behalf at any time (refresh_token, offline_access).
- Click “Save”.
Verify Your Connected App
Before continuing, please verify that your Connected App is set up correctly and that you have the following information:
- Callback URL
- Selected OAuth Scopes
- Access and manage your data (api)
- Perform requests on your behalf at any time (refresh_token, offline_access)
- Consumer Key (also known as Client ID)
- Consumer Secret (also known as Client Secret)
Now that your Connected App has been created in Salesforce, you can go to your Ninja Forms settings to connect Ninja Forms to your Salesforce account. Connecting WordPress to your Salesforce account is a two-step process. Generating your Consumer Key and Consumer Secret is the first step. The second step is generating an Authorization Code. This second step ensures that only you, who can log into your Salesforce account, is authorized to use that Consumer Key and Secret.
Save Your Consumer Key and Consumer Secret in Ninja Forms
- In your dashboard, go to Ninja Forms Settings.
- Scroll to the Salesforce Settings section.
- Enter your Consumer Key and Consumer Secret.
- SAVE your settings.
Generate Your Authorization Code
- After saving your Consumer Key and Consumer Secret, click the link “Click to generate open authorization code”.
- You will be redirected to Salesforce and asked to log in, if you are not already logged in.
- After being logged in, you will then be redirected to a page that says “Remote Access Application Authorization”.
- On this page, the URL that is in the address bar of your browser contains the authorization code you need.
- Copy the authorization code (the entire address) and paste it into the Authorization Code box in the Salesforce Settings.
- SAVE your settings.
Generate Your Refresh Token
IMMEDIATELY after saving your authorization code:
- Click the link “Click to generate refresh token”.
- Ninja Forms will use your Consumer Key, Consumer Secret, and this Authorization Code to generate a Refresh Token. This token is what now allows Ninja Forms to submit form data directly into your Salesforce account for you.
Verifying Your Authorization
The callback URL in your Salesforce connected app must match exactly as specified:
Open Auth Scopes
The following two scopes must be enabled in your connected app:
Access and manage your data (api)
Perform requests on your behalf at any time (refresh_token, offline_access)
Saving Your Settings
After entering your Consumer Key and Consumer Secret, SAVE your settings before continuing.
After entering your Authorization Code, SAVE your settings.
Click to generate the refresh token IMMEDIATELY after saving.
Retrieving Your Salesforce Objects and Fields
Your Salesforce account has objects (ex: Accounts, Contacts, Leads) and fields within those objects (ex: First Name, Last Name, Phone) into which you wish to send your Ninja Forms’ submissions. Once you have successfully connected to your Salesforce account by performing the authorization steps, you can retrieve your objects and fields by:
By default, the fields for the Leads object is retrieved. Below the list of fields is a complete list of all the objects you have in your Salesforce account. If you wish to use different or additional objects:
- Copy those objects from the object list and paste them into the “Objects to Retrieve” box, separating the objects with a comma “,”.
- SAVE your settings.
- Click the link “Click to retrieve your Objects and fields”.
The fields for your desired objects are now loaded into Ninja Forms for use in all your forms.
Mapping Your Form Fields to Salesforce
After you have created your form in Ninja Forms, the final step is to map your form fields into where you’d like them to go in your Salesforce account. Here’s how to do that:
- Go to the Emails & Actions section of your form design.
- Click “+” to add a new action.
- Select “Add to Salesforce”.
- Click “Salesforce Field Map +” to add a new field map.
- In the Form Field box:
- Click the gray icon to pull up a list of all your form fields.
- Select the form field you wish to use.
- If you want to send a specific value instead of a submitted form value, type the value directly into the box (ex: “3 days”).
- In the Salesforce Field, use the drop down list to select to which field in your Salesforce account you wish to send this data.
- (Optional) Data Handling Instructions lets you do the following:
- Check for duplicates in this field. If Ninja Forms finds a duplicate in your Salesforce account, a task will be created to notify you of the possible duplicate.
- Format the field as a date interval. If you want to set a date in the future based on the submission date, click this field and set the form field to the desired date interval.
- Format the field as a date. Salesforce as a specific date format required, but this format may not be what you want to appear on your form. By selecting this option, your form value will be converted into the date format required by Salesforce.
When you are done, click “Done” and publish your form. Your form submissions will now be sent to Salesforce. Congratulations!