Creating Salesforce Task with Flow
In certain steps of the document generation process, you can log activities by creating a task or an event record in Salesforce.
In the template builder, switch to Advanced View
In the Home tab, select Main Flow
As an example, select the Exit step, this step will execute when the Exit button is clicked.
Click on Edit Step
In the Search bar, look for the command create
Drag the create command before the finish command
In the right pane, give the Salesforce Object API in type attribute.
If you want to create a task, type:Task
If you want to create an event, type:Event
Drag and drop
field
tag from SFDC Core Calls to the logic, as a child tag ofcreate
Next, click on the field command. The first field command should always contain the record id.
In the
field
tag attributes in the right pane, give value to the name attribute:name:
OwnerId
In the value attribute, select the "..." icon to open Data Source
Search for a Salesforce field where you have the id of the user, who you want to have the task assigned to. For example, the task will be assigned to end-user who is creating the document at that time, search for User ID field under the User object
Click to the field, then select Set Attribute
The field API name will be populated in the value attributeRelate task or event to other records
The task or event can be related to another record so that it will appear in the Activities related list of the record. For example, end-user runs Dynamo template to create a document for an Opportunity record. Then the template will create a task for end-users to follow up with that opportunity.Similar to step 4, drag and drop a field tag as a child tag of the create
In the
field
attributes, give value:name:
WhatId
value: Salesforce field to refer to record ID of the related record, for example:
${Opportunity.Id}
Add content to the task or event
You need content to at least fill all the required fields when creating a new task or event. Similar to step 4 and 5, drag and drop more fields tag under the create tag to populate the content. See the table below for field references.The name attribute: the Salesforce API name of a field in the Task or Event object
The value attribute: the content to be filled in for the mentioned field. Value can be text, dynamic data from other Salesforce fields, result from calculation or a combination of those
Name attribute | Description / | Example of values | Required in Task | Required in Event |
---|---|---|---|---|
OwnerID | Contains the ID of the user who owns the task/ event. Label is Assigned to | ${User.Id} | Required | Required |
Subject | The subject line of the task / event. Label is Subject | Follow-up: ${Opportunity.Name} | Required | Required |
Status | The status of the task, such as In Progress or Completed. Label is Status | Completed | Required | |
Priority | Indicates the importance or urgency of a task, such as high or low. Label is Priority | Normal | ||
WhatID | Record ID of the related object. Label is Related To | ${Opportunity.Id} | ||
WhoID | Record ID of the related Contact or Lead. Label is Name | ${PrimaryContactRole.Contact.Id} | ||
StartDateTime | The start date and time of the event. Label is Start | ${today} | ||
ActivityDate | The event due date. Label is Date | ${today.plusDays(14)} | ||
EndDateTime | The end date and time of the event. Label is End |
For more field references see:
Example: Log activity after sending document via email
Whenever end-users send a quotation to an Opportunity, you want to log an activity to the Opportunity record, with information such as:The day the document has been sent
Email addresses the document has been sent to
The file name of the document
To achieve this requirement, you can follow the instruction above to:
Add create and field tags to the logic on the "Send Option - End" step
Add value to the field tag as the example below
A "Completed" task will be created after the email is sent. End-user will be the task owner. The task is related to the opportunity record in which the document is generated, and referred to the Primary Contact of that opportunity.