1. Open your Salesforce and create a new Document Action.
  2. Document Action custom object will be installed in your org as soon as the package completed installation.
    1. You can access it in two ways: via selecting from All Tabs menu or via RS Documents App.
    2. To access All Tabs menu click “+” on your tab menu and select Document Action from the list of available tabs:
      RS Document Action Tab
    3. To access from RS Documents App switch app to “RS Documents App” from the top right corner, then select Document Actions tab from the tab menu:
      App

      DocumentActionTab
  3. After selecting “Document Actions” tab click  “New” button to create a new Document Action:

    NewDocumentAction

 

Section ‘Document Action Detail’ (Top Section): 

  • Action ID: Auto-numbered ID generated for Document Action identification.
  • Action Name: reference name of the action you wish to setup (e.g. “Generate Quote”, “Download Contract”, “Email and Download Invoice” etc.)
  • Base object API. Provide the API name of the Object where the RS Documents App will be used (e.g. if you are generating invoice with the data merged from Opportunity, then you should put “Opportunity” into Base Object API field)
    • API names for standard Salesforce object are listed here (refer to blue underlined object names). Typically it will be exact name of the object with no space, like: Lead, Account, Contact, Opportunity, Case etc.
    • To access API names for custom object go to Setup, under App Setup on the left toolbar click “Create”, select  “Manage your custom objects” function or “Objects” (if expanded from the toolbar).
      • Find a custom object and click on it.
      • You will find an API Name field in Custom Object Definition Detail page:
        InvoiceAPI
  • Field to Update & Field to Update To: This field is not required. Purpose of this field is to automatically update a picklist status to another status value on the object record you generate document from. For example you have a standard picklist field on Opportunity” object called ‘Stage’ which shows which stage the Opportunity is at. You could have a the Opportunity record be in picklist status “Quote Requested” and then once you generated document on this record, you could automatically update this field status to “Quote Sent.”
  • Template Document ID: paste Google Docs document ID that you have saved from the previous step.
  • Folder ID: This field is not required. If you would like all generated documents from this document action to be placed inside a folder on Google Drive, enter ID of the Google Drive folder where generated document will be saved (make sure folder has open access to the app users generating documents there). If you leave this field blank, the generated document will be saved in the same folder where Google Docs template is located.
    • You can find Google Drive folder ID  by clicking on the folder in your Google Drive and copying ID value from the URL:Screen Shot 2015-02-18 at 3.01.11 PM
    • Optional Advanced Configuration for Google Drive Folder ID: You also have the option to dynamically pass the Google Docs folder ID in custom button URL so generated document goes directly to Google Docs folder: Take the button code from Document Action to paste into custom button and then add: &folderId={folder id field} at the end of the custom URL. Example: https://rsdoc.na10.visual.force.com/apex/GenerateDocument?id=a02F000000RKLsz&templateId=GDT-000476&attach=true&output=pdf&emailAction=Autosend&emailTo=003F000002FuH0P&emailTemplate=00XF0000001jK8U&emailToAdditional=mpavluchenko%40sclode.com&folderId=0BxNC7wi8NG3hRzZRTEltT3NZTkE  (****notice &folderId=0BxNC7wi8NG3hRzZRTEltT3NZTkE)

Section Properties of Merged Document in Google Drive:

  • Visibility. Set up the visibility options for the document you are going to generate. Options are the same as standard Google Docs sharing setting options: Private, Company, Link, Public:
    • Private – Only you can access. If you are the only user to generate documents and using the app, then you can use this setting. If anyone else tries to generate a document with this setting or access your generated document, they will not be able too.
    • Company – You can choose this option only if you have a Google Apps For Work /G Suite for your company. Setting “Visibility” field to “Company” will allow any users in your company to have automatic access to the merged document from the “Shared with Me” folder in their Google Drive accounts.
      • If you DO have a Google Apps For Work account, then go to Setup > Develop > Custom Settings > Click ‘Manage’ next to Google Apps Domain Setting. If you have a previously set “Company_Domain” setting, then check that it has your company domain in the Value field (which should match your Google Drive domain). If you need to create a new one, the name should be “Company_Domain” and the value will be the last part of your company email address that comes after the “@” symbol. For example take, support@ramseysolutions.com email, the value would be “ramseysolutions.com.” You will not be able to save the “company” setting inside document action before you do this step.
      • If you do NOT have a Google Apps For Work account, then you can either sign up for one, or just use the “Visibility: Link” setting instead, and make sure to specify a value for “Save URL to Salesforce Field”. This will allow anyone in your company who goes to that Salesforce record, to still be able to click on the URL link and go directly to the document. In addition, you can also use the “Save URL to Salesforce Field” link in any email templates that you create. You could then use that email template as an alternate means to send your merged Google Drive document to a list of users in your company.
      • NOTE: If you try to merge a document with “Visibility” set to “Company” and the Google Drive account you used to authenticate isn’t a company account, you’ll receive the alert, “Error while sharing document. Error message: Permission not found”.
    • Link – This is the most popular option that most app customers use. This option allows “anyone with the link” to access the generated documents if they have the full google doc link, example: “https://docs.google.com/document/d/1xl9QO-IDDGYoJ6CwJ6G-2UU5Kuz9omCsFdFbP-zV5sg/edit” sent to them via email and can access the generated document from the Google Doc URL link on Salesforce record.
    • Public –  Choosing this option means that anyone will be able to access your generated documents.
  • Access. Set up the access restrictions options for the Document you are going to generate. Options are the same as standard Google Docs access options: Can View, Can Comment, Can Edit.
  • Save URL to Salesforce Field. This field is not required to fill out. However, completing this field will allow you to save the URL to the generated document to the Base Object page layout.
    • Create a custom field on the Base Object. (find steps on how to create custom fields on Standard vs Custom objects here).
    • Use field type “Text” (link will be saved as a string of text, you will have to copy and paste it into your browser to access) or “URL” (link will be saved as a URL link and will be clickable directly from the layout).
    • Copy the API name of the newly created field and paste it in the Document Action settings.
      DocAPI


Section “Properties of Merged Document in Salesforce:” 

  • Attach file to record. This field is not required. If you check this box, a copy of the generated document will be attached to your Salesforce record. Standard is for the generated document to create an ‘attachment’ and show under your Notes & Attachments related list on object layout. Should you prefer the generate a ‘File’ or a ‘Document’ instead of ‘attachment,’ you can configure this in your custom settings under Setup:
    • To use Salesforce ‘Files’ instead of Attachments, go Setup > App Setup > Develop > Custom Settings > Click on ‘RS Documents’ link > Click on ‘Manage’ next to RS Documents Settings > Click ‘Edit’ >  Check box to ‘Use Files’ checkbox and click ‘Save.’ You can then modify your object page layout to pull the ‘Files’ related list onto layout to access generated files from each record.
    • To use Salesforce ‘Documents’ instead of Attachments or Files,  go to Setup > App Setup > Develop > Custom Settings > Click on ‘RS Documents’ link > Click on ‘Manage’ next to RS Documents Settings > Click ‘Edit’ > Check box to ‘Use Documents’ and click ‘Save.’
      • When using ‘documents,’ the copy of generated document will go to your Documents tab (go to + sign for more tabs). You will not see the generated document go under your record like using Attachments or Files as it is not a related list.
      • If you would like to specify a folder for the generated documents to go into under Documents, click to modify Document Action page layout and add the custom field ‘Documents Folder’ to the layout (suggested placement next to Google Doc ID/Folder ID in top section). Then paste your ‘Document Unique Name’ into this field on document action. The unique name will look like an API name with no spaces, example “Opportunity_Generated_Quotes.”
    • It is possible to generate an attachment and a file. Or a file and a document. Or all three if you wanted, just modify the custom settings per the instructions above to have additional box checked.
  • Output format. This field is required if you check field box above to “attach file to record.” If this parameter is provided, new document gets downloaded in the output format and attached to the Salesforce record. Supported outputs are:
  1. .docx
  2. .html
  3. .odt
  4. .pdf
  5. .rtf
  6. .txt
  • Download File. This field is not required. If you check this box, a copy of the generated document will go to your ‘downloads’ folder on your computer.
    • NOTE: It is mandatory that you allow Pop Ups from Salesforce domain as browsers are interpreting this “download” action as a popup in new window. If you are’t sure if your pop ups are already approved, you will notice that when you attempt to generate a document for download to your computer, there is usually an indication that a pop up was blocked and you have the option to approve that URL for the future. Once the URL is approved, you should not have to do this step again.
  • Delete Google Doc After Merge. This field is not required. If you check this box, the copy of generated document will automatically get deleted from your google drive. If you do not check this box, a copy of the generated document will go to your google drive each time you generate a document.
    • NOTE: You cannot check this box to delete google doc if you have box checked to “Download file.” Both features do not work together so you have to use individually in document action.
    • NOTE: You also cannot check this box to delete google doc if you have box checked to “Save URL to Salesforce” field in document action. You wouldn’t be able to access the google doc URL from record if you deleted it so both features do not work together.

Section “Email:”

  • This entire section is optional.  Allows you to automatically/manually send newly generated document to the predefined Lead or Contact.
  • Email Action.
    • Select  “Autosend” if you would like to automatically send out an email with attached document.
    • Select  “Preview” if you would like to preview your email before sending.
  • Email To.
    • Create a merge field to the Lead or Contact ID that will be pulled from each object record you generate the document from. You will build this merge field within the custom button code screen (see “HELP” text below email section in document action and click on the “HERE” button to bring you to custom button where you can find the base object relationship to the Lead or Contact ID field). The merge field code should always include “ID” towards the end so you know you are merging the correct one.
    • You can also enter Lead or Contact ID of the recipient if it’s always the same person that you want to email generated document too. You can find the ID in the URL of the Contact/Lead record:
      ContactID
  • Email To Additional and Email CC and Email BCC. Fields used to specify additional email addresses that will be put into “To”, “CC” or “BCC” fields of the email. Enter email addresses separated by comma.
  • Email From Org Wide Address. Optionally you can set default email address that you want the email to be sent from. See this article for more detail and steps to set this feature up.
  • Email Template (Classic only). ID of the template that will be used in the email message (you can find directions on how to create and manage Classic email templates in Salesforce here).
    • You can find the email template ID in the URL of the template (NOTE: The email template ID will always start with the letters “OOX“):
      Email Template ID

 Section “eSignature:”

  • This section is only to be used if combining automation with our RS Signature app to send generated document for eSignature. 
  • If you are sending generated document for eSignature, you can see step by step documentation for “Using RS Documents with RS Signature for Full Automation” section here.

“Save” your Document Action to Generate Custom Code: 
Once you have completed all needed fields in document action, click “Save” to save your Document action. A completed Document Action will auto-generate Action ID and Button/Link Code:

  • Button/Link Code. Code for the Button or Link that will be used for Document generation (copy this value to your clipboard, you will need it in the next step). In addition you can manually setup what Salesforce fields to update upon Document Generation by adding in the end of this code next variables: &fieldtoupdate1=StageName&fieldtoupdatevalue1=Proposal Sent, where:
    • &fieldtoupdate1= API Name of the field that you want to update (Opportunity stage in our Example)
    • &fieldtoupdatevalue1=New value of the field (In our example new value will be “Proposal Sent”)
    • Put  consequential  after variable if you want to update more than one field: &fieldtoupdate1=API_Field1&fiedtoupdatevalue1=Field1_NewVale….&fieldtoupdateN=API_FieldN&fiedtoupdatevalueN=FieldN_NewVale*field to update cannot be used with boolean fields, like checkbox

 

ButtonCode