Git Product home page Git Product logo

sf-field-history's Introduction

Salesforce Field History Retrieval

A lightweight Python command line utility that backs up Salesforce Field History data for long term storage.

Setup

Python Setup

Install Requests library, http://docs.python-requests.org/en/master/user/install/

Salesforce Connected App

You will need to create a Salesforce Connected app

  • Go to Setup > Create > Apps
  • Scroll down to Connected Apps, click New
  • Enter the App Name, sf-field-history
  • Enter Basic Information as necessary. Best practice is to use a service account rather than assigning to a specific administrator so that application access is not interrupted if an administrator leaves your team.
  • Callback URL is required but is not necessary for this application. Enter the URL of your salesforce instance.
  • Set OAuth scopes:
    • Access and Manage Your Data (api). Feel free to create custom permissions as needed.
  • None of the information under Custom Connected App Handler, Mobile App Settings, or Canvas App Settings is required
  • Click Save

Credential and Org Management

  • Copy the .sample.env file and rename to .env.
  • Add site URI, do not include https://
  • Enter user credentials including OAuth Consumer Key and Consumer Secret

Requirements

  • Python v2.7 or greater
  • User with Salesforce API access

Usage

Run Locally

Retrieve logs for a given environment

$ python retrieveHistory.py {orgname}
>>Fetching logs from, orgname.cs32.my.salesforce.com

Run in debug mode

$ python retrieveHistory.py orgname -d
Fetching logs from, myOrgName.cs32.my.salesforce.com
Debug has been turned on, logs will be stored at logs/20190209-2212.52.log

Display list of environments stored in .env

$ python retrieveHistory.py -e
The following environments have credentials stored:
  - orgname1
  - orgname2
  - orgname3
You can use one of the sites by entering:

  $ python retrieveHistory.py orgname

Display help

$ python retrieveHistory.py -h
usage: retrieveHistory.py [-h] [-e] [-d] [orgName]

Salesforce Field History Retrieval This python script will authenticate
against Salesforce and pull json responses containing field history data.
Request responses are logged in the /logs directory. Each run of this app will
generate multiple requests, those requests are merged into a single log file

positional arguments:
  orgName      enter the org key of the environment contained in .env

optional arguments:
  -h, --help   show this help message and exit
  -e, --env    display list of Salesforce environments contained in the .env
               file
  -d, --debug  Prints detailed output to the /logs folder

Setup CRON Job

$ crontab -e
0 1 * * * path/to/retrieveHistory.py {orgname}

FAQ & Troubleshooting

500 Response on sa.authenticate() Typically results from outdated OpenSSL library resulting in a TLS 1.0 call. Salesforce requires TLS 1.1 or greater connections. Upgrade OpenSSL library to resolve

sf-field-history's People

Contributors

mvogelgesang avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.