09/26/2019

By Ram Yarramasu | Reading time 6 mins

Adding Table to the Email Template in Dynamics CRM 365

Ever wondered why Sales is one of the pivotal departments in an organization? It’s not easy to meet a stranger, talk about your service or product within a short span of time and convince him/her to reach into the pocket and shell out some money.

 

The unique and important role of Sales is to bridge the gap between the potential customer’s needs and the products/services that the organization offers that can fulfill their requirements. And every organization has its own way of doing sales including approaching customers, making deals, selling products/services and involving a unique sales pipeline.

 

Now in such a high pulsating environment, you can’t expect a Sales rep to shuffle between several systems to get the information on one client. This can lead to an immense wastage of time and resources and maybe the loss of a potential client.

Adding Table to the Email Template in Dynamics CRM 365 - AhaApps

15 Questions to Identify the Gaps in Your CRM

CRM Checklist - AhaApps
With Dynamics 365, the whole story gets a fresh spin. Your sales rep can find all the answers in one system. The time that was spent moving from one application to the other, can now be utilized to pitch the product/service to another client. Thus, eventually increasing your ROI.

 

Even though Dynamics 365 is one of the most trustworthy and scalable CRMs around, it isn’t devoid of certain challenges. We are aware of the role that emails play in our professional lives.  For Sales, using it in CRM, is like a lifeline as so many functionalities are attached to it. Such as connecting with the customer, sending out quotes, discussing deadlines, creating approval requests and so on.

 

This widely used communication feature needs to be a hassle-free affair for any professional. However, there are certain limitations to it as well in the Dynamics CRM. Let’s discuss.

Problem:

Adding tables or HTML contents with out of box features and a little bit of custom code instead of designing completely new email templates.

Background:

In general, a company’s sales depend on so many factors but in my opinion, the sales representative is the primary aspect. There is a lot a sales representative can do- reaching out to leads/prospects, explaining the products, providing quotes, making offers, providing discounts. And finally selling the product/service. In such cases, there will be a lot of emails that keep on ricocheting between the rep and the client.

 

Customers look for products at affordable prices and mostly try to enquire with other competitors for different features and one of the main aspects is the cost. Everyone wants the best but at an affordable price range. So, most of the organizations give permissions to the sales representative to apply discounts to match with the competition.

Reason:

When an organization gives permission to a sales representative for applying discounts on quotes, the business may have an approval process in place to ensure that the discount is limited based on the positions. A sales representative will create a quote, request for an approval decision (if it crosses the sales rep max discount limit) which needs a green signal from the manager/Director of Sales/Vice President of Sales. This is a hectic process wherein the rep must go through each record for their approvals.

 

An approver might want to see who the customer is, what are the products that have been requested for the discount and the discount rate. Now if all this information gets added, it will certainly increase the size of the email.

 

In order to make it shorter, a table format for all the data can be used and the data will appear in an organized manner. However, adding tables to an email message description is not an in-built feature. In this scenario, the table needs to be dynamic as well (needs to contain rows as per the number of quote details or products).

Solution:

Generally, we use workflows to send automated email messages where we can send an email or create one and send it in later. For adding a table to the email description, we use Create Email Message and the email message will be created with the details intended to keep.

 

A replacing string in the email description needs to be added where the table is placed. This replacing string later is used in custom workflow plugin step to insert table.

 

It’s important to have a custom workflow, which will execute with the context of the created email message.

 

[Input(“E-Mail”)]

[ReferenceTarget(“email”)]

public InArgument Email { get; set; }

protected override void Execute(CodeActivityContext executionContext)

{

IOrganizationService _service = servicefactory.CreateOrganizationService(context.UserId);

var tableData = ProductCategoryTable.Get(executionContext);

if (!string.IsNullOrEmpty(tableData))

{

Entity email = _service.Retrieve(“email”,

Email.Get(executionContext).Id,new ColumnSet(“description”));

tableData = GetTable(_service, QuoteGuid);

email.Attributes[Constants.Email.Description] =

email.Attributes[“description”].ToString().Replace(“[replacingString]”, tableData);

service.Update(email);

}

_service.Execute(new SendEmailRequest()

{

EmailId = Email.Get(executionContext).Id,

IssueSend = true,

TrackingToken = string.Empty

});

}

private string GetProductCategoryDiscountTable(IOrganizationService _service, string quoteGuid)

{

var tablestring = string.Empty;

var GetProductCategoryRollups = @”

mapping=’logical’ distinct=’false’>

”;

var productDetails =

_service.RetrieveMultiple(new FetchExpression(string.Format(GetProductCategoryRollups, quoteGuid))).Entities.ToList();

if(productCategoryRollups.Count > 0)

{

foreach(var product in productDetails)

{

tablestring = “

” + “

” +

product.GetAttributeValue(“product_id”).Name + “

” + “

”+

Decimal.Round(product.GetAttributeValue(“amount”).Value, 2) + “

” +

” + Decimal.Round(product.GetAttributeValue(“discountAmount”).Value, 2)

+ “

” + “

” + product.GetAttributeValue(“discountPercentage”) + “%”

+ “

” + “

” + tablestring;

}

}

if (tablestring!= string.Empty)

{

//This is to add colum headers

tablestring = “

” ++ “” + “” + “” + “” +” + tablestring + “

” + “NAME” + “

” + “AMOUNT” +

” + “DISCOUNT” + “” + “DISCOUNT PERCENTAGE” + “

}

return tablestring;

}

 

Our certified consultants can help bridge the gap by classifying main requirements, developing CRM roadmaps, and restructuring lead-to-cash implementations. Connect with us for changing the way your business operates.

Author’s bio:

Kiran has been associated with AhaApps since 2018 as a Microsoft Dynamics CRM Developer. He is passionate about CRM and is zealous to provide the best and efficient solutions to his clients using his analytical, logical expertise. He loves to play cricket on the field when he gets time. And sometimes likes to watch his favorite series on the telly. He is also fond of trying out games on the mobile.

Field Security In Dynamics 365

Do you know how to enable the field security option in Dynamics CRM? Our blog tells you how.