/rp-form

Salesforce form template for ResearchPark

Primary LanguageApexMIT LicenseMIT

rp-form

Salesforce form template for ResearchPark

Development Instruction

Preparation

The instruction is for MacOS.

  1. Install Homebrew

  2. Install Atom

    brew cask install atom
  3. Install MavensMate Desktop

  4. Install MavensMate-Atom

    apm install MavensMate-Atom
  5. Login into salesforce, goto Setup

  6. Goto Deploy -> Sandboxes on the left explorer. Click New Sanebox to create a new sandbox. Select Developer license and click Next.

  7. After your sandbox created, select New Project in MavinsMate Desktop, and choose type Sandbox. It allows to log in your project by web auth and you need the auth code from your manager.

  8. After logging in, you're ready for development.

Structure

To get your familiar with the salesforce, here are some basic components.

  • Object (Custom Object)
    • Object is the most important component in salesforce to store any information you collected form the users. It's like the database at the end.
    • Goto Create -> Objects on the left explorer to view all the objects and to create new type of object.
  • Visualforce Page / Visualforce Component
    • Visualforce Page or Component performs ui.
    • You can write html / css / js or apex component in it.
    • Here's an intruduction to visualforce
  • Apex Classes
    • Apex Classes is the controller part in the mvc structure.
    • It could connect to Visualforce Page and perform some actions.

Form Template

This repository provide you a basic form template. It's built on several open source libraries such as jQuery and BootStarp. I suggest to editing on this base since it can provide many general well-designed modules and there is no need to rewrite them.

The form is consisted by the following parts:

  • Custom Object: Information to be collected and prompts.
  • Visualforce Page: UI
  • Apex Classes: Verify and save information.

You have to complete at least these three parts, if you needs more customization such as email notification or SPA, please follow the rest part of the document.

Make sure you are working in sandboxes

Custom Object

The first step is to define a custom object which could save the information you wish to collected. It could also provide some additional prompt text.

  1. Goto Create -> Objects under Setup tab. Click on New Custom Object to create a new object.
  2. Follow the instruction and the example, type in the name and label. You do not need to modify any fields other than the required one. Click Save.
  3. Create or modified the fields under the Custom Fields & Relationships tab.
  4. There're two fields important and need to be remembered. API Name will be used in the Apex Classes, and Help Text will be displayed on the webpage.

Apex Classes

  1. Create an Apex Classes, copy and paste the Apex_Classes_Template.cls.
  2. Replace all CUSTOM_OBJECT_API_NAME with the API Name of the object you just created.
  3. You need to fill the fieldName in Apex Classes so the backend could pass the reference to the client. For example, for the following fieldName
      '---',
      'h:Referral Partner\'s Contact Information',
      'p:All requests for small business assistant services must come from referrals from partners including; incubators, SBDC, PTAC offices, ITCs, University of Illinois Extension Offices, or higher education entrepreneurial programs.',
      'Referring_Partner_s_Name_Organization__c',
      'Referring_Partner_s_Phone__c',
      'Referring_Partner_s_Email__c',
    
    --- will be an horizontal line in the page, h:xxx will be a header with bold and larger font, p:xxx will be the prompt text, and other fields s.t. Referring_Partner_s_Phone__c should be the field API name that you defined before.

Visualforce Page

  1. Create a VisualForce Page, copy and past the VisualForce_Page_Template.page.
  2. Replace all CUSTOM_OBJECT_API_NAME with the API Name of the object you just created.
  3. The title and the introduction section can be customized. Replace the following section to modify them.
    • __FORM_TITLE__
    • __ADDITIONAL_SECTION__
    • __ADDITIONAL_INFORMATION__

Deployment to Production

Salesforce uses a mechanism called "Inbound / Outbound"

  1. Log into your sandbox. Goto Deploy -> Outbound Change Sets.
  2. Create a new change set, add the component you wish to apply to master. And add its dependencies.
  3. Upload the change set.

Accessibility to Public

TODO

Email Notification

To send an email notification to either the user who submitted the form or the manager who will review the requests,

  1. Create email template. Goto Communication Templates -> Email Templates, and create a new template with the content you wish to send to the user or the manager.
  2. Create workflow. Goto Workflow & Approvals -> Email Alerts, and create a new action, select the template you just created and the recipients
  3. Create rule. Goto Workflow & Approvals -> Workflow Rules, and create a new rule. Select the related object and choose criteria, then check the related action.
  4. Finally deploy to production, then active it.

Advanced: SPA

TODO