Navigation

Wednesday, March 18, 2020

Salesforce Outlook Integration - Ability to edit the Email message.



Outlook Integration with Salesforce  (Ability to associate attachment into related record and Ability to Edit the Email Messages)



This blog series will help you to understand and configure the Outlook to salesforce and associate the email message attachment into a related record along with editing privileges on the email message after inserting it into salesforce. 


Outlook integration:

     Many of us are struggling to integrate the outlook into salesforce, but this blog will help you to implement the same step by step along with a screenshot.  


Email Message Attachment Associate into Related Record:

    In Salesforce email message attachment will be saved under the same email message, it’s very hard to view & navigate from related records, but this blog will help you to associate the email message attachment into a related record.  Users can see the attachment on the related record itself, no need to navigate into the email message to view the attachments. 


Ability to edit the Email Message 

    The general behaviour of the email message in salesforce is that we can't edit
the email message after it’s associated with salesforce, but this blog will help you edit the email message at any time. 


Configuring the Outlook Setting in salesforce :

Step 1: Login Salesforce Dev/Sandbox/production org.

Step 2:  After login into the salesforce, click on the setup →  Quick Find → Outlook Integration And Sync And Enable the Outlook Integration and Lightning Sync as shown below. 





Step 3: Expand Outlook Integration and In Email Application Publisher
Layouts Click the new button to create a new layout.


  

Step 4: Click on the edit button to edit the existing layout.



Step 5: Add or Remove quick action to the layout in order to access the outlook Panel, example contact, task, lead, Account in Outlook etc…




Integration & Adding salesforce Plugin into outlook


Step 1: Log in to the Outlook Office365 Account(Enter the Username and Password)
   
Step 2: Select the Outlook

A screenshot of a cell phone

Description automatically generated


Step 3: Click the App Launcher Icon:

A screenshot of a cell phone

Description automatically generated

Step 3: Click on the  “All apps” link to view the existing plug-ins as shown below. 

A screenshot of a cell phone

Description automatically generated

Step 4:  Click on the “Add-Ins” option to add the salesforce plug in. 

A screenshot of a cell phone

Description automatically generated

Step 5:  Search “Salesforce ” on the Search bar.
A screenshot of a cell phone

Description automatically generated

Step 6: Select Salesforce from the Drop Drown menu:

A screenshot of a cell phone

Description automatically generated


Step 7: Click to “Get it Now” to install the plug in outlook. 

A screenshot of a cell phone

Description automatically generated

Step 8: Click “Continue” from the popup window as shown below. 
A screenshot of a social media post

Description automatically generated

Step 9: The following screen will apply and Click Open in Outlook Web


Step 10: Open the email and click “More Action”  then Scroll down for more action and click Salesforce icon.



Step 11:  Select “Salesforce”  Then Click to “log in to salesforce” and then Enter the username and password


Step 12: Click to “Allow”

A screenshot of a cell phone

Description automatically generated
Step 13: It will redirect into a salesforce account then enter the Username and Password.


Step 14: Click on the confirm button to connect the outlook into salesforce. 




Step 15: Now successfully logged your developer account from outlook.




Step 16: Make sure you enabled Enhanced Email->Enabled>Attachment Goes to Email Message(Object)





Step 17: Enhanced Email->Disabled>Attachment goes to Contact ->Activity->Task.







 Step 18:  If no contact is found in salesforce, Click the "Add to Salesforce" link to create a record in salesforce or use the Create button to create a record.


Step 19: Click + Create icon to create a new task, Event, Contact, Account, etc.......


Step 20: if not display the object here we need to create quick action in global action and add publisher layout.



Step 21:then we need to add quick action  object into Email application publisher layout so that we can able to see the object into outlook


Step 22: Click to log Email along with Attachment checkbox tick and click Save.



Step 23: Attachment added into salesforce


Step 24: Click “Show this is record sale in salesforce" button.


Step 25: It will Create one task added attachment show in below



Step 26: Click Account name “outlook 2” it will Redirect into account page layout shows the attachment showing in files.


Step 27: Click edit button to modify email message it will redirect in custom Visualforce page 



Step 29: we need to override the standard Email Message “edit” button so that we can 
redirect.



Step 28:it will vf page and Modify the date and text body and subject then click save.




Content Version Trigger  - This Trigger will be used to convert the attachment from Email message to related record. 

/************************************************
Trigger Name : CopyToRelatedRecord
Description : To create a attachment on the request object based on the Outlook email associated attachments.
Created by : Sampath Arjunan
Created Date : 16th March 2020
Last Modified Date : 16th March 2020
*************************************************/
trigger CopyToRelatedRecord on ContentVersion (after insert,after update) {
system.debug('****');
for(ContentVersion aDoc : Trigger.new){
system.debug('%%%%'+aDoc);
ContentVersion theFile = [SELECT Title, ContentDocumentId, FileType, VersionData FROM ContentVersion WHERE id=:aDoc.Id];
List<ContentDocumentLink> listlink = [SELECT LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId=:theFile.ContentDocumentId];
for(ContentDocumentLink link : listlink){
String parentID = link.LinkedEntityId;
Blob BodyData = theFile.VersionData;
system.debug('&&&&&'+parentID);
system.debug('&&&&&@@@'+parentID.substring(0,3));
if(parentID.substring(0,3) == '02s'){
Emailmessage existingmessage = [Select RelatedToId From Emailmessage Where Id =:parentID LIMIT 1];
//Task theTask = [SELECT ActivityDate,CallObject,CreatedDate,Id,OwnerId,Status,Subject,TaskSubtype,Type,WhatId,WhoId FROM Task WHERE Id=:parentID];
//system.debug('^^^^'+theTask);
//if(theTask.WhatId != null && theTask.TaskSubtype=='Email'){
//system.debug('****'+theTask);
/*Attachment anAttachment = new Attachment();
anAttachment.Body = BodyData;
anAttachment.ContentType = theFile.FileType;
anAttachment.Name = theFile.Title;
anAttachment.ParentId = theTask.WhatId;
insert anAttachment;*/
Id varContentDocumentId = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id =: theFile.Id].ContentDocumentId;
List<ContentDocumentLink> listcondoclinks = [select id, ContentDocumentId from ContentDocumentLink
where LinkedEntityId=:existingmessage.RelatedToId and ContentDocumentId=:varContentDocumentId];
if(listcondoclinks.size() <=0){
ContentDocumentLink cdl = new ContentDocumentLink();
cdl.ContentDocumentId = varContentDocumentId;
cdl.LinkedEntityId = existingmessage.RelatedToId;
cdl.ShareType = 'V';
insert cdl;
}
}
}
}
}
Email Message Trigger - This trigger is used to change the status of the Email Message to draft status so that the user can edit the email message. 

/************************************************
Trigger Name : UpdateStatus
Description : To update the draft status of email message
Created by : Sampath Arjunan
Created Date : 9th April 2020
Last Modified Date : 9th April 2020
*************************************************/
trigger UpdateStatus on EmailMessage (before insert) {
for(EmailMessage newMessage:trigger.new){
newMessage.status='5';
}
}
EmailMessageEditOverride - This Visual force page used to override the Edit button on Email Message. 

<apex:page standardController="EmailMessage" lightningStylesheets="true">
<apex:form >
<apex:pageblock >
<apex:pageblockSection >
<apex:inputfield value="{!Emailmessage.messageDate}"/>
<apex:inputfield value="{!Emailmessage.Subject}"/>
<apex:inputfield value="{!Emailmessage.Textbody}"/>
</apex:pageblockSection>
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageblockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
TestClass - To cover the test coverage for the above two triggers. 

/************************************************
Class Name : CopyToRelatedRecord_Test
Description : Test class for CopyToRelatedRecord
Created by : Sampath Arjunan
Created Date : 9th April 2020
Last Modified Date : 9th April 2020
*************************************************/
@isTest
public class CopyToRelatedRecord_Test {
@isTest static void CopyToRelatedRecord_Test()
{
Test.startTest();
//Create Document Parent Record
Account acc = new Account(Name='Test Account');
Insert acc;
Contact c = new Contact(FirstName='TestContact',Lastname='TestLastName',email='test@test.com',accountid=acc.id);
insert c;
Task t = new Task(Subject='TestSubject',ActivityDate=system.today(),whatid=acc.Id,whoid=c.id,TaskSubtype='Email');
insert t;
Emailmessage createmessage = new EmailMessage();
createmessage.status='5';
createmessage.MessageDate=System.today();
createmessage.RelatedToId=acc.Id;
createmessage.FromAddress=c.email;
createmessage.FromName=c.name;
createmessage.TextBody='newMessage.TextBody';
createmessage.Subject='newMessage.Subject';
createmessage.ToAddress=c.email;
createmessage.HtmlBody='newMessage.HtmlBody';
insert createmessage;
//Create Document
ContentVersion cv = new ContentVersion();
cv.Title = 'Test Document';
cv.PathOnClient = 'TestDocument.pdf';
cv.VersionData = Blob.valueOf('Test Content');
cv.IsMajorVersion = true;
Insert cv;
//Get Content Documents
Id conDocId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cv.Id].ContentDocumentId;
//Create ContentDocumentLink
ContentDocumentLink cdl = New ContentDocumentLink();
cdl.LinkedEntityId = createmessage.Id;
cdl.ContentDocumentId = conDocId;
cdl.ShareType = 'V';
cdl.Visibility = 'AllUsers';
Insert cdl;
system.debug('&&&&&'+cdl);
update cv;
system.assertEquals(conDocId,cdl.ContentDocumentId);
test.stopTest();
}
}

Programming Lightning Web Components (DEX602)

Programming Lightning Web Components (DEX602)

Day1 - Introducing Lightning Web Components

The Lightning Web Components Model
Creating Lightning Web Components
Styling Components
Defining Component Properties
Handling DOM Events
Debugging Lightning Web Components
Working with Salesforce Data
Using Base Lightning Components
Raising and Handling Events

Advanced Communication Between Components


Day 2 - Surfacing Lightning Web Components

Building Lightning Pages with Components and App Builder
Building Components for Lightning Experience Record Pages
Surfacing Lightning Web Components
Overriding Standard Actions
Defining a Lightning Application
Using Lightning in Visualforce Pages with Lightning Out

Other Supported Experiences


Day 3 - Implementing Navigation and Layouts

Using lightning-vertical-navigation
Using lightning-datatable
Implementing Button Groups

Building Responsive Layouts


Day 4 - Building Advanced Components

Creating a Custom, Responsive Datatable
Defining Public Functions on Components
Service Components and Toast Notifications
Slots and Modal Notifications
Localization
Renderers and Third-Party JS


Day 5 - Working with Data

Implementing Forms

Implementing Forms with Custom Controls
Validating Input Data
Viewing and Editing Salesforce Records
Waiting for Server Requests to Complete

Day 6 - Working with Source-Tracked Orgs

Day 7 - Org Development Model and Deployments

Day 8 - Testing Lightning Web Components with Jest

Day 9 - Lightning Web Components for Aura Developers