Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Generate and attach report to email for CRM Online

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

Anyone has a WFA library that can generate and attach a report to an email?

Possible to use the same method like on-premise?

Thanks!

====================================================

var rsExec = new ReportExecutionService();
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Url = reportServerAddress;

//Load report
rsExec.LoadReport(reportFolderAndName, historyId);

// pass parameters
rsExec.SetExecutionParameters(new ParameterValue[] { new ParameterValue() { Name = "ApplicationId", Value = ApplicationRecord.Get<EntityReference>(executionContext).Id.ToString() } }, null);

//List of Format XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, and Word
Byte[] result = rsExec.Render(AttachmentFormat.Get<String>(executionContext), deviceInfo,
out extension, out encoding,
out mimeType, out warnings, out streamIDs);

Entity attachment = new Entity("activitymimeattachment");
attachment["filename"] = AttachmentName.Get<String>(executionContext);
attachment["subject"] = AttachmentSubject.Get<String>(executionContext);
attachment["body"] = Convert.ToBase64String(result);
attachment["mimetype"] = "application/octet-stream";
attachment["objectid"] = new EntityReference("email", EntityType.Get<EntityReference>(executionContext).Id);
attachment["objecttypecode"] = "email";

service.Create(attachment);

*This post is locked for comments

  • Suggested answer
    MSCRM Guru Profile Picture
    MSCRM Guru 600 on at
    RE: Generate and attach report to email for CRM Online

    Hi,

    It's not possible to access the reporting services directly with CRM Online / Dynamics 365.  I would try to utilise various workarounds like this one: https://community.dynamics.com/crm/f/117/t/205829 or this one: http://crmpankaj.blogspot.com.au/2016/01/generate-pdf-file-using-java-script-in.html

    These do all the work in JavaScript, but essentially they show the web requests needed which can be converted to be used in a Workflow activity.

    Good luck!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans