rodriggj / saleforce_dev

0 stars 0 forks source link

5. Adding Static Resources to Car Object #14

Closed rodriggj closed 2 years ago

rodriggj commented 2 years ago

It is often common to Seed an Org with preliminary test data. You don't want to have to hand-jam a bunch of records into our Org so we can use them for testing and development purposes. To do this Salesforce provides an option via the Static Resource Service to help load records to your Custom Objects by ingesting a file (e.g CSV) that has these records already maintained.

rodriggj commented 2 years ago

Source Data:

rodriggj commented 2 years ago
  1. Download the csv and the zip file from the reference links above an place on Desktop
  2. Go to Setup / Static Resources / New
  3. On the next page populate the form data with the following updates, the other fields you can leave as default. Click Save
    • File: Upload the zip file
    • Name: provide a name
    • Cache Control : Public
  4. Open Google Chrome Developer Tools
  5. Click Inspect on the View File anchor Tag. Select Console and then $0 on the console terminal.
  6. You will see the URL for the image resource. You need the id number.

rodriggj commented 2 years ago
  1. Go to the .csv file
  2. In Column A you see a bunch of URL resources that all have an id number in the URL. We need to replace this URL ID number. Click "Find and Replace" and swap the id you extracted from the earlier step.

rodriggj commented 2 years ago
  1. Go back to SFDC
  2. Go to Setup / Car Hub / Cars / Import
  3. Click Cars
  4. Click Upload CSV & choose the modified file
  5. Click Next

  1. The next screen should show mapped fields, click Next

  1. Finally you will confirm the import of static resources. When you click Next you will be informed that the import has stated click Ok

rodriggj commented 2 years ago
  1. The next screen will confirm a Bulk Data Load Job completed

NOTE: The output of the Bulk Upload Service for whatever reason, 4 Records of the 14 available on Car_Data3.csv file were not loaded. The record import failed.

  1. If you now nav back to our app at App Manager / Car Hub / Car and select All Records you should see multiple Car records loaded in our application.

rodriggj commented 2 years ago

NOTE: Excellent use case for a Testing Suite. Look at the Import source file and the records that came into salesforce. Here we validate that 4 records were not imported.

rodriggj commented 2 years ago

How does this Impact Automated Testing Tools

  1. Testing of Object records typically cannot be done through the front-end UI. You will need functionality that allows you to execute SOQL and or API queries on the back-end directly to the Salesforce Lightning Data Service or to the Database directly via a connection string.
  2. A testing suite will need to be able to test as a profile that has Scope and Roles that allow for API calls and / or SOQL queries.
  3. State in a Database changes all the time, therefore, an automated tool needs to be able to be incorporated into a Scheduling capability of some kind. This may be possible via a CRON, Pipeline, or Automated Schedule within the Testing Tool suite itself.