SlideShare a Scribd company logo
Google Apps Script
​ Shashidhar Gurumurthy
​ Technical Solution Architect
​ sgurumurthy@salesforce.com
​ 
Minimal Fuss Data Transformation using Google Apps Script
Agenda
v Google Apps Script – What, Why & WIIFM
v Getting Started
v Some Transformations
v Interacting with Salesforce
v Preserving Parent /Child Relationship without External Id
Overview
A brief overview of ‘What’ & ‘Why’ Google Apps Script
What’s Google Apps Script
v A scripting language based on Javascript
v Let’s you work with Google Apps such as Docs, Sheets & Forms by
extending their functionality
v Add custom menus, dialogs and sidebars to Google Docs, Sheets & Forms
v Write custom functions for Google Sheets
v Publish web apps – either standalone or embedded in Google Sites
v Interact with other Google Services such as AdSense, Analytics, Calendar,
Drive, Gmail & Maps
Why Google Apps Script
v Familiarity
v Ease of a spreadsheet
v Known language: Javascript
v If you have a Google account, you have Google Apps Script
v Nothing to install – code editor right in the browser
v Runs on Google infrastructure
v Better than Excel/CSVs – no corruption of special characters
Relevancy
​ What’s in it for me?
v Most Salesforce projects have a data management requirement.
v Data loads from internal & external sources
v  Change formats
v  Combining files, splitting files
v Data loads between Production & Sandbox environments
v  Maintain parent child relationships
v Excel/CSV not very efficient (manual steps required) whereas ETL tools are,
probably, an overkill during early stages of a project.
v Google Apps Script provides a middle ground to automate (script) data
transformations.
Overview Demo
​ Getting Started
On a Google Spreadsheet,
select Tools > Script editor
New Project with one code
element opens up.
Write some code & save. Run
& authorize access to app to
access data.
Services and Functions
Some theory before we get into the juicy bits
Key Services & Classes
​ Key functions
v SpreadsheetApp: Allows users to open Google Sheets and to create new ones.
This class is the parent class for the Spreadsheet service.
v  getActive().addMenu()
v ScriptApp: Access and manipulate script publishing and triggers.
v  getService().getUrl() – returns web url – used for OAuth redirect url.
v PropertiesService: Allows scripts to store simple data in key-value pairs scoped
to one script, one user of a script, or one document in which an add-on is used.
v  getScriptProperties()
v  getUserProperties()
v  getDocumentProperties()
Key Services & Classes
Key functions
v HtmlService: This service allows scripts to return HTML, usually as a user
interface.
v  createHtmlOutput()
v Utilities: This service provides utilities for string encoding/decoding, date
formatting, JSON manipulation, and other miscellaneous tasks.
v URL Fetch Service: This service allows scripts to access other resources on the
web by fetching URLs. Supports HTTP headers and methods.
v  fetch(url, options)
v Many other services such as Calendar, Contacts, Drive, Document, Mail Service,
Gmail and other advanced Google services are available.
Reading & Writing Sheets
​ Key Functions and Usage
v getActiveSpreadsheet(): Returns the currently active spreadsheet or null if there
is none.
v getActiveSheet(): Returns the active sheet in a spreadsheet.
v openById(id) and openByUrl(url): Opens the spreadsheet with the given id/url.
v spreadsheet.getSheetByName(name): Within a spreadsheet, get a particular
sheet by name.
v setActiveSheet(sheet): Sets the active sheet in a spreadsheet.
v setActiveSpreadsheet(newActiveSpreadsheet): Sets the active spreadsheet.
Reading & Writing Sheets
​ Key Functions and Usage
v clear(): Clears the sheet of content and formatting information.
v clearContents(): Clears the sheet of contents, while preserving formatting.
v clearFormats(): Clears the sheet of formats, while preserving contents.
v getDataRange(): Returns a range corresponding to the dimensions in which
data is present.
v getRange(): Get a range of cells using rows & columns or cell name notation.
v range.getValues(): Returns the rectangular grid of values for this range.
v appendRow(rowContents): Append a row to the sheet.
Usage Scenarios
Typical scenarios where you will find a use for Google Apps Script
Utilities
Reading & Writing Sheets
Normalize Data
Lookup
DEMO
Read from / Write to Salesforce
v Setup Connected App on Salesforce
v Setup OAuth flow on Apps Script
v Connect to Salesforce using UrlFetch Service
Connected App Setup on Salesforce
Save OAuth Parameters as Script Properties
OAuth Flow
Step 1 – Show Page with link to start OAuth Flow
Step 2 – Post Auth, Salesforce redirects to published web app
OAuth Flow - Continued
Step 3 – Use the code to get & store access & refresh tokens
Using the Access Token
Reading Data from Salesforce
DEMO
Preserving Parent Child Relationship Across Orgs
v Having external id on the parent object makes it easy
v What if you don’t have an external id and easily need to copy data?
v Steps:
v Load Parent object and save new parent ids
v Create mapping between old parent ids and new parent ids
v When loading Child object, use the mapping data to point the Child
to the correct Parent object
Insert the Parent Object
Create Mapping Between the Parent IDs
Insert the Child Object
DEMO
Reference Material
v Google Apps Script Home: https://developers.google.com/apps-script/
v YouTube Video – Integrating Google Apps with Salesforce using
Google Apps Script (Arun Nagarajan, Nov 2012):
http://bit.ly/1M9OWur
v YouTube Video – Integrating Salesforce.com with Google Apps
(Arun Nagarajan, Dreamforce 2013): http://bit.ly/1LWnCwE
v This Presentation: Session’s Chatter Feed on Dreamforce App
v Code: https://github.com/shashig/df15-google-apps-script
v Spreadsheet to go with demo code: http://bit.ly/1LF0TCI
Q & A
Thank you

More Related Content

What's hot

Design Patterns for Asynchronous Apex
Design Patterns for Asynchronous ApexDesign Patterns for Asynchronous Apex
Design Patterns for Asynchronous Apex
Salesforce Developers
 
Qa qc supervisor kpi
Qa qc supervisor kpiQa qc supervisor kpi
Qa qc supervisor kpi
povitjom
 
Prozess-Skript 2.0 D
Prozess-Skript 2.0 DProzess-Skript 2.0 D
Prozess-Skript 2.0 DWandelBarCamp
 
APIs do LinkedIn
APIs do LinkedInAPIs do LinkedIn
APIs do LinkedIn
LinkedIn
 
From Lead to Cash Vision
From Lead to Cash Vision From Lead to Cash Vision
From Lead to Cash Vision
Dennis Stoutjesdijk
 
REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!
Dimitri Gielis
 

What's hot (6)

Design Patterns for Asynchronous Apex
Design Patterns for Asynchronous ApexDesign Patterns for Asynchronous Apex
Design Patterns for Asynchronous Apex
 
Qa qc supervisor kpi
Qa qc supervisor kpiQa qc supervisor kpi
Qa qc supervisor kpi
 
Prozess-Skript 2.0 D
Prozess-Skript 2.0 DProzess-Skript 2.0 D
Prozess-Skript 2.0 D
 
APIs do LinkedIn
APIs do LinkedInAPIs do LinkedIn
APIs do LinkedIn
 
From Lead to Cash Vision
From Lead to Cash Vision From Lead to Cash Vision
From Lead to Cash Vision
 
REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!
 

Similar to Minimal Fuss Data Transformation Using Google Apps Scripts

sveltekit-en.pdf
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
ssuser65180a
 
App Service Web
App Service WebApp Service Web
App Service Web
Lisa Muthukumar
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Development
joelabrahamsson
 
Tech Lead-Sachidanand Sharma
Tech Lead-Sachidanand SharmaTech Lead-Sachidanand Sharma
Tech Lead-Sachidanand Sharma
Sachidanand Semwal
 
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Rodolfo Finochietti
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
Evan Mullins
 
MongoDB.local Berlin: App development in a Serverless World
MongoDB.local Berlin: App development in a Serverless WorldMongoDB.local Berlin: App development in a Serverless World
MongoDB.local Berlin: App development in a Serverless World
MongoDB
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
Dave Bost
 
Industrial training in .net
Industrial training in .netIndustrial training in .net
Industrial training in .net
ResistiveTechnosource Pvt. Ltd.
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
Sauce Labs
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
Evan Mullins
 
Azure web apps
Azure web appsAzure web apps
Azure web apps
Vaibhav Gujral
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
Evan Mullins
 
Developing windows azure and web services brochure exam code 70-487
Developing windows azure and web services brochure   exam code 70-487Developing windows azure and web services brochure   exam code 70-487
Developing windows azure and web services brochure exam code 70-487
Zabeel Institute
 
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App EngineJava Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
IMC Institute
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
Robert J. Stein
 
Cloud computing overview & Technical intro to Google Cloud
Cloud computing overview & Technical intro to Google CloudCloud computing overview & Technical intro to Google Cloud
Cloud computing overview & Technical intro to Google Cloud
wesley chun
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
Evan Mullins
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
Software Park Thailand
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
Juan Antonio
 

Similar to Minimal Fuss Data Transformation Using Google Apps Scripts (20)

sveltekit-en.pdf
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
 
App Service Web
App Service WebApp Service Web
App Service Web
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Development
 
Tech Lead-Sachidanand Sharma
Tech Lead-Sachidanand SharmaTech Lead-Sachidanand Sharma
Tech Lead-Sachidanand Sharma
 
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
MongoDB.local Berlin: App development in a Serverless World
MongoDB.local Berlin: App development in a Serverless WorldMongoDB.local Berlin: App development in a Serverless World
MongoDB.local Berlin: App development in a Serverless World
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
 
Industrial training in .net
Industrial training in .netIndustrial training in .net
Industrial training in .net
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
 
Azure web apps
Azure web appsAzure web apps
Azure web apps
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
 
Developing windows azure and web services brochure exam code 70-487
Developing windows azure and web services brochure   exam code 70-487Developing windows azure and web services brochure   exam code 70-487
Developing windows azure and web services brochure exam code 70-487
 
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App EngineJava Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
 
Cloud computing overview & Technical intro to Google Cloud
Cloud computing overview & Technical intro to Google CloudCloud computing overview & Technical intro to Google Cloud
Cloud computing overview & Technical intro to Google Cloud
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
 

More from Salesforce Developers

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Salesforce Developers
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
Salesforce Developers
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
Salesforce Developers
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX India
Salesforce Developers
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local Development
Salesforce Developers
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web Components
Salesforce Developers
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
Salesforce Developers
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer Highlights
Salesforce Developers
 
Live coding with LWC
Live coding with LWCLive coding with LWC
Live coding with LWC
Salesforce Developers
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and Testing
Salesforce Developers
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
Salesforce Developers
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
Salesforce Developers
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCP
Salesforce Developers
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in Salesforce
Salesforce Developers
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data Capture
Salesforce Developers
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DX
Salesforce Developers
 
Get Into Lightning Flow Development
Get Into Lightning Flow DevelopmentGet Into Lightning Flow Development
Get Into Lightning Flow Development
Salesforce Developers
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS Connect
Salesforce Developers
 

More from Salesforce Developers (20)

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component Performance
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX India
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local Development
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web Components
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer Highlights
 
Live coding with LWC
Live coding with LWCLive coding with LWC
Live coding with LWC
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and Testing
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCP
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in Salesforce
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data Capture
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DX
 
Get Into Lightning Flow Development
Get Into Lightning Flow DevelopmentGet Into Lightning Flow Development
Get Into Lightning Flow Development
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS Connect
 

Recently uploaded

Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 

Recently uploaded (20)

Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 

Minimal Fuss Data Transformation Using Google Apps Scripts

  • 1. Google Apps Script ​ Shashidhar Gurumurthy ​ Technical Solution Architect ​ sgurumurthy@salesforce.com ​  Minimal Fuss Data Transformation using Google Apps Script
  • 2. Agenda v Google Apps Script – What, Why & WIIFM v Getting Started v Some Transformations v Interacting with Salesforce v Preserving Parent /Child Relationship without External Id
  • 3. Overview A brief overview of ‘What’ & ‘Why’ Google Apps Script
  • 4. What’s Google Apps Script v A scripting language based on Javascript v Let’s you work with Google Apps such as Docs, Sheets & Forms by extending their functionality v Add custom menus, dialogs and sidebars to Google Docs, Sheets & Forms v Write custom functions for Google Sheets v Publish web apps – either standalone or embedded in Google Sites v Interact with other Google Services such as AdSense, Analytics, Calendar, Drive, Gmail & Maps
  • 5. Why Google Apps Script v Familiarity v Ease of a spreadsheet v Known language: Javascript v If you have a Google account, you have Google Apps Script v Nothing to install – code editor right in the browser v Runs on Google infrastructure v Better than Excel/CSVs – no corruption of special characters
  • 6. Relevancy ​ What’s in it for me? v Most Salesforce projects have a data management requirement. v Data loads from internal & external sources v  Change formats v  Combining files, splitting files v Data loads between Production & Sandbox environments v  Maintain parent child relationships v Excel/CSV not very efficient (manual steps required) whereas ETL tools are, probably, an overkill during early stages of a project. v Google Apps Script provides a middle ground to automate (script) data transformations.
  • 7. Overview Demo ​ Getting Started On a Google Spreadsheet, select Tools > Script editor New Project with one code element opens up. Write some code & save. Run & authorize access to app to access data.
  • 8. Services and Functions Some theory before we get into the juicy bits
  • 9. Key Services & Classes ​ Key functions v SpreadsheetApp: Allows users to open Google Sheets and to create new ones. This class is the parent class for the Spreadsheet service. v  getActive().addMenu() v ScriptApp: Access and manipulate script publishing and triggers. v  getService().getUrl() – returns web url – used for OAuth redirect url. v PropertiesService: Allows scripts to store simple data in key-value pairs scoped to one script, one user of a script, or one document in which an add-on is used. v  getScriptProperties() v  getUserProperties() v  getDocumentProperties()
  • 10. Key Services & Classes Key functions v HtmlService: This service allows scripts to return HTML, usually as a user interface. v  createHtmlOutput() v Utilities: This service provides utilities for string encoding/decoding, date formatting, JSON manipulation, and other miscellaneous tasks. v URL Fetch Service: This service allows scripts to access other resources on the web by fetching URLs. Supports HTTP headers and methods. v  fetch(url, options) v Many other services such as Calendar, Contacts, Drive, Document, Mail Service, Gmail and other advanced Google services are available.
  • 11. Reading & Writing Sheets ​ Key Functions and Usage v getActiveSpreadsheet(): Returns the currently active spreadsheet or null if there is none. v getActiveSheet(): Returns the active sheet in a spreadsheet. v openById(id) and openByUrl(url): Opens the spreadsheet with the given id/url. v spreadsheet.getSheetByName(name): Within a spreadsheet, get a particular sheet by name. v setActiveSheet(sheet): Sets the active sheet in a spreadsheet. v setActiveSpreadsheet(newActiveSpreadsheet): Sets the active spreadsheet.
  • 12. Reading & Writing Sheets ​ Key Functions and Usage v clear(): Clears the sheet of content and formatting information. v clearContents(): Clears the sheet of contents, while preserving formatting. v clearFormats(): Clears the sheet of formats, while preserving contents. v getDataRange(): Returns a range corresponding to the dimensions in which data is present. v getRange(): Get a range of cells using rows & columns or cell name notation. v range.getValues(): Returns the rectangular grid of values for this range. v appendRow(rowContents): Append a row to the sheet.
  • 13. Usage Scenarios Typical scenarios where you will find a use for Google Apps Script
  • 18. Read from / Write to Salesforce v Setup Connected App on Salesforce v Setup OAuth flow on Apps Script v Connect to Salesforce using UrlFetch Service
  • 19. Connected App Setup on Salesforce
  • 20. Save OAuth Parameters as Script Properties
  • 21. OAuth Flow Step 1 – Show Page with link to start OAuth Flow Step 2 – Post Auth, Salesforce redirects to published web app
  • 22. OAuth Flow - Continued Step 3 – Use the code to get & store access & refresh tokens
  • 24. Reading Data from Salesforce DEMO
  • 25. Preserving Parent Child Relationship Across Orgs v Having external id on the parent object makes it easy v What if you don’t have an external id and easily need to copy data? v Steps: v Load Parent object and save new parent ids v Create mapping between old parent ids and new parent ids v When loading Child object, use the mapping data to point the Child to the correct Parent object
  • 27. Create Mapping Between the Parent IDs
  • 28. Insert the Child Object DEMO
  • 29. Reference Material v Google Apps Script Home: https://developers.google.com/apps-script/ v YouTube Video – Integrating Google Apps with Salesforce using Google Apps Script (Arun Nagarajan, Nov 2012): http://bit.ly/1M9OWur v YouTube Video – Integrating Salesforce.com with Google Apps (Arun Nagarajan, Dreamforce 2013): http://bit.ly/1LWnCwE v This Presentation: Session’s Chatter Feed on Dreamforce App v Code: https://github.com/shashig/df15-google-apps-script v Spreadsheet to go with demo code: http://bit.ly/1LF0TCI
  • 30. Q & A