Google Integration
Google GSuite
Frappe allows you to use Google's GSuite documents as templates, generate from them a new GSuite document that will be placed in a chosen folder. Variables can populated in both the body and the name of the GSuite document using the standard Jinja2 format. Once generated, the Gsuite document will remain associate to the DocType as an attachment.
The GSuite document is generated by invoking the "attach file" function of any DocType.
A common use cases of this features is populating contracts from customer/employee/supplier data.
1. Enable integration with Google Gsuite
1.1 Publish Google apps script
If you will use the default script, you can skip and go directly to step 1.2
Create a new Project. Click on File > New > Project
Copy the code of Desk > Explore > Integrations > GSuite Settings > Google Apps Script to clipboard and paste to an empty Code.gs in script.google.com
Save the Project. Click on File > Save > Enter new project name
Deploy the app. Click on Publish > Deploy as web app
Copy "Current web app URL" into Desk > Explore > Integrations > GSuite Settings > Script URL
Click on OK but don't close the script
1.2 Get Google access
Go to your Google project console and select your project or create a new one. https://console.developers.google.com
In Library click on Google Drive API and Enable
Click on Credentials > Create Credentials > OAuth Client ID
Fill the form with:
Web Application
Authorized redirect URI as
http://{{ your_site }}/?cmd=frappe.integrations.doctype.gsuite_settings.gsuite_settings.gsuite_callback
Copy the Client ID and Client Secret into Desk > Explore > Integrations > GSuite Settings > Client ID and Client Secret
Save GSuite Settings
1.3 Test Script
Click on Allow GSuite Access and you will be redirected to select the user and give access. If you have any error please verify you are using the correct Authorized Redirect URI. You can find the complete URI GSuite redirected to in the final part of the URL of the error page. Check that the protocol
http://orhttps://matches the one your using.Click on Run Script test. You should be asked to give permission.
2. GSuite Templates
2.1 Google Document as Template
Create a new Document or use one you already have. Set variables as you need. Variables are defined with
{{VARIABLE}}with VARIABLE is the field of your DoctypeFor Example, If this document will be used to employee and the Doctype has the field name then you can use it in Google Docs ad
{{name}}Get the ID of that Document from URL of your document. For example: in this document URL
https://docs.google.com/document/d/1Y2_btbwSqPIILLcJstHnSm1u5dgYE0QJspcZBImZQso/editthe document ID is1Y2_btbwSqPIILLcJstHnSm1u5dgYE0QJspcZBImZQsoGet the ID of the folder where you want to place the generated documents. (You can step this point if you want to place the generated documents in Google Drive root. )
For example: in this folder URL
https://drive.google.com/drive/u/0/folders/0BxmFzZZUHbgyQzVJNzY5eG5jbmcthe folder ID is0BxmFzZZUHbgyQzVJNzY5eG5jbmc
2.2 Associate the Template to a Doctype
Go to Desk > Explore > Integrations > GSuite Templates > New
Fill the form with:
Template Name (Example:
Employee Contract)Related DocType (Example:
Employee)Template ID is the Document ID you get from your Google Docs (Example:
1Y2_btbwSqPIILLcJstHnSm1u5dgYE0QJspcZBImZQso)Document name is the name of the new files. You can use field from DocType (Example:
Employee Contract of {name})Destination ID is the folder ID of your files created from this Template. (Example:
0BxmFzZZUHbgyQzVJNzY5eG5jbmc)
3. Create Documents
Go to a Document you already have a Template for (Example: Employee > John Doe)
Click on Attach File
On GSuite Document section select the Template and click Attach
You should see the generated document is already created and attached
Clicking on the attached document will open it inside GSuite
Google Calendar Integration
TechMaju provides an integration with Google Calendar in order for all users to synchronize their events.
Setup
In order to allow a synchronization with Google Calendar you need to connect to your application in Google Cloud Platform and then create an account for each of your users:
Create a new project on Google Cloud Platform and generate new OAuth 2.0 credentials
Add
https://{your_site}to Authorized JavaScript originsAdd
https://{your_site}?cmd=frappe.integrations.doctype.gcalendar_settings.gcalendar_settings.google_callbackas an authorized redirect URIAdd your Client ID and Client Secret in the GCalendar application: in "Modules>Integrations>Google Calendar>GCalendar Settings"
Once this step is successfully completed, each user can create their own account in Google Calendar > GCalendar Account. They will be requested to authorize your Google application to access their calendar information and will then be redirected to a success page.
Features
Creation of a new calendar in Google Calendar
Each User can choose a dedicated name for their Google Calendar.
Events synchronization from TechMaju to GCalendar
All Events created in TechMaju are created in Google Calendar.
Recurring Events are created as recurring events too.
You can optionally add a Google Meet conference link to the Event.
All participants (User email) will be added to the Event.
Events modified in TechMaju are updated in Google Calendar.
Events deleted in TechMaju are deleted in Google Calendar.
Events synchronization from GCalendar to TechMaju
Events created in Google Calendar are created in TechMaju.
Events updated in Google Calendar are updated in TechMaju.
The synchronization module follows TechMaju's authorization rule: An event will be only synchronized if it is public or if the user is the owner.
Limitations
Currently, if an instance of a recurring event is cancelled in Google Calendar, this change will not be reflected in TechMaju.