Custom Outlook Button for Record Email Link in Dynamics CE

Custom Outlook Button for Record Email Link in Dynamics CE

To create a ribbon button in Dynamics 365 CRM that emails a link to the record in Outlook, we can follow these general steps:

1. Create a JavaScript Web Resource:

Write a JavaScript function that retrieves the record information and composes the email. This function should be triggered when the button is clicked.

function getEmailLinkData(ctrl) {

'use strict';

var formContext = ctrl;

var recordId = formContext.data.entity.getId();

var recordName = formContext.data.entity.getEntityName();

var recordDisplayName = formContext.data.entity.getPrimaryAttributeValue();

// Construct the link to the CRM record

var crmRecordLink = formContext.context.getClientUrl() + "/main.aspx?etc=" + formContext.context.getQueryStringParameters().etc + "&id=" + recordId + "&pagetype=entityrecord";

return {

recordName: recordName,

recordDisplayName: recordDisplayName,

crmRecordLink: crmRecordLink

};

}

function openOutlookEmail(ctrl) {

'use strict';

var formContext = ctrl;

var emailData = getEmailLinkData();

// Compose the email body

var emailBody = "Record Name: " + emailData.recordDisplayName + "\n" +

"Link: " + emailData.crmRecordLink;

// Compose the mailto link

var subject = formContext.getAttribute("subject").getValue();

var mailtoLink = "mailto:?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(emailBody);

// Open the default email client (Outlook)

window.location.href = mailtoLink;

}

2. Upload the Web Resource:

Upload the JavaScript file as a Web Resource in Dynamics 365 CRM.

3. Customize the Ribbon:

Use Ribbon Workbench or the built-in customization options in Dynamics 365 to add a button to the ribbon of the desired entity.

Associate the button with the JavaScript function you created.

4. Define the Button's Command:

Specify the command for the button, and associate it with the JavaScript function.

5. Add the Button to the Form:

Customize the entity form to include the newly created button.

This will directly open the Outlook email client with pre-filled content , the record link in the email body and the subject as Subject of the email.

Remember to test thoroughly and consider security and compliance considerations when implementing such functionality in your CRM environment.


I hope you found this article useful and informative. I would love to hear your feedback, thoughts, or suggestions. You can contact me at [email protected] or send me a message on LinkedIn Komal Ridda Malik.

Happy reading!

Ola A.

Solutions Architect - D365 & Azure Services at Sciensus | Togaf | MCT | Power Platform | Azure | FinOps | CE Apps | PSM I

1 年

要查看或添加评论,请登录

Komal Ridda Malik的更多文章

社区洞察

其他会员也浏览了