Skip to main content

Configure the Email to Salesforce functionality for airSlate

Y
Written by Yuliia Biletska
Updated over 2 months ago

airSlate’s Email to Salesforce functionality addresses the following use cases:

Case 1: I don’t want to use airSlate email notifications to send links to documents to my users. Can I get a link to a document that is included in the emails my users send?

Case 2: I want to store copies of emails sent from airSlate in Salesforce records, is that possible?

Case 3: Can I store links to create a revision in a Salesforce field, so that users can edit documents generated from Salesforce?

Follow the steps below to adjust the Email to Salesforce functionality within the airSlate integration:


1. Navigate to Setup to activate the Email to Salesforce functionality. Then, search for Email to Salesforce in the Quick Find box. Once located, select Edit.

Activate the functionality by selecting the corresponding checkbox. Then, save your settings.

2. From your personal settings, enter email to salesforce in the Quick Find box. Then, select My Email to Salesforce.

Proceed to the My Acceptable Email Addresses section. Next, add the following emails divided by a comma with no space: [email protected],[email protected]. These emails are used by airSlate to send the original email with a link to a document. Once finished, click Save.

3. In airSlate, create a new or select an existing workflow you want to configure the Email to Salesforce functionality for. At this step, you need a document with a hidden field where the record ID will be stored.

Tip: If no field to store the record ID in your workflow documents exists, you will need to create it. To add a hidden field, you can create a document with a hidden field (web form), or add a hidden document with the field to your workflow.

In the airSlate workflow builder, add and configure the Pre-fill fields from Salesforce bot to pre-fill the hidden field with the Salesforce starting record ID.

4. Add the Salesforce email address to step.

Tip: To retrieve the Salesforce email, navigate to the personal settingsMy email to Salesforce. Then, copy the email address link.

5. Proceed to the step settings by clicking the gear icon next to the step. In the Document and forms section, uncheck the Revoke access checkbox. This will allow recipients to open a document from Salesforce for editing via a link.

In the Recipient section, customize the email subject by adding ref: recordID. The recordID is a data variable where the Salesforce record ID is stored. Once done, click Apply.

Tip: To ensure that the document does not lock after filling for the first time via link from Salesforce, add one more step in the workflow builder without changing any default settings. This will allow for multiple revisions of the same document to be created.

Once the document is created from Salesforce (via an airSlate custom button, Salesforce Flow, or Process), the record ID will be passed to the email subject. The email with the document link will be sent to a Salesforce email address. Salesforce logic will then create a Task object with the corresponding email.

If you need to take the URL from the Task and place it into a Salesforce field, you can use the following solution.


In this example, we take the URL from the Task and write this URL into the FillOutLink__c field in the object that has been specified in the email subject (Contact in our example).

Tip: To create the FillOutLink__c field, navigate to Object managerSalesforce objectFields & RelationshipsNew.


The FillOutLink__c field should have a Text Area (Long) type with at least 350 characters allocated for it (because a normal text field will truncate the fill out link).

Note: If you use the Production environment, you won’t be able to create Apex Classes directly in the Salesforce organization. In this case, you will need to use the Sandbox environment to deploy these Apex Classes from Sandbox to Production.

6. Now, proceed to adding new Apex Classes and Triggers.

1. Add TaskTriggerHandler (Apex Class):


To add a new Apex Class, go to SetupApex Classes New.

Note: The fillOutTitle variable may change. If the trigger isn’t working, check the created Task (you can find it under the starting record or in unresolved items) and put the title above the necessary link in the fillOutTitle variable.

public class TaskTriggerHandler {

public static final String fillOutTitle = 'Fill out documents:';

public static final String ref = 'ref:';

public static String getRefId(String subject) {

Id refId = null;

List<String> subjectFields = subject.split(' ');

Boolean afterRef = false;

for (String field : subjectFields) {

if (field.startsWith(ref)) {

afterRef = true;

} else if (afterRef && (field instanceof Id)) {

refId = field;

break;

}

}

return refId;

}

public static String getFillOutLink(Task t) {

String fillOutLinkStart = 'https://link.airslate.com/r/m?';

String fillOutLink = null;

List<String> rows = t.Description.split('\n');

Boolean afterFillOutTitle = false;

for (String row : rows) {

System.debug(row);

if (row.startsWith(fillOutTitle)) {

System.debug('row.startsWith(fillOutTitle)');

afterFillOutTitle = true;

} else if (afterFillOutTitle && row.startsWith(fillOutLinkStart)) {

System.debug('afterFillOutTitle && row.startsWith(fillOutLinkStart)');

row = row.replace('&amp;', '&');

fillOutLink = row;

break;

}

}

return fillOutLink;

}

}

2. Add Trigger:


To add a new trigger, go to SetupTriggers.

trigger TaskTrigger on Task (before insert) {

Map<Id, String> refIdsToLinks = new Map<Id, String>();

for (Task t : Trigger.new) {

if (String.isNotBlank(t.Description)

&& t.Description.contains(TaskTriggerHandler.fillOutTitle)

&& String.isNotBlank(t.Subject)

&& t.Subject.contains(TaskTriggerHandler.ref)) {

System.debug(t.Description);

String fillOutLink = TaskTriggerHandler.getFillOutLink(t);

Id refId = TaskTriggerHandler.getRefId(t.Subject);

if (String.isNotBlank(fillOutLink) && refId != null) {

refIdsToLinks.put(refId, fillOutLink);

}

}

}

List<Contact> toUpdate = [SELECT Id FROM Contact WHERE Id IN :refIdsToLinks.keySet()];

for (Contact contact : toUpdate) {

contact.FillOutLink__c = refIdsToLinks.get(contact.Id);

}

update toUpdate;

}

3. Add TaskTriggerHandlerTest (Apex class):

@IsTest

private class TaskTriggerHandlerTest {

@IsTest

private static void test_getRefId() {

Contact testContact = new Contact(LastName = 'Contact');

insert testContact;

String subject = TaskTriggerHandler.ref + ' ' + testContact.Id;

String refId = TaskTriggerHandler.getRefId(subject);

System.assertEquals(testContact.Id, refId);

}

@IsTest

private static void testTrigger() {

Contact testContact = new Contact(LastName = 'Contact');

insert testContact;

String toCheckLink = 'https://link.airslate.com/r/m?test';

Task testTask = new Task(

Subject = TaskTriggerHandler.ref + ' ' + testContact.Id,

Description = 'Some description\n'

+ '\n'

+ TaskTriggerHandler.fillOutTitle + '\n'

+ toCheckLink + '\n'

+ 'Cheers!'

);

insert testTask;

testContact = [SELECT FillOutLink__c FROM Contact WHERE Id = :testContact.Id];

System.assertEquals(toCheckLink, testContact.FillOutLink__c);

}

}

Did this answer your question?