{"id":23116,"date":"2020-03-20T13:31:30","date_gmt":"2020-03-20T13:31:30","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=23116"},"modified":"2020-03-20T13:31:30","modified_gmt":"2020-03-20T13:31:30","slug":"how-to-send-email-with-attached-dynamics-365-crm-report-in-resco-mobile-app","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2020\/03\/how-to-send-email-with-attached-dynamics-365-crm-report-in-resco-mobile-app\/","title":{"rendered":"How to send Email with Attached Dynamics 365 CRM Report in Resco Mobile App"},"content":{"rendered":"<p><strong>Introduction:<\/strong><\/p>\n<p>Recently we had a business requirement, where we needed to send Dynamics 365 CRM Report through Email from Resco Mobile App. In this blog, you will see how to do the same. To achieve this, \u00a0follow the steps given below:<\/p>\n<p>1) We added a custom button (i.e.Command) on the Entity Form of the <strong>Invoice<\/strong> entity. Please refer below screenshots:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-23117\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_1.png\" alt=\"\" width=\"1366\" height=\"620\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_1.png 1366w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_1-300x136.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_1-768x349.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_1-1024x465.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_1-660x300.png 660w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<p style=\"padding-left: 40px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-23119\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_2.png\" alt=\"\" width=\"602\" height=\"472\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_2.png 602w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_2-300x235.png 300w\" sizes=\"(max-width: 602px) 100vw, 602px\" \/><\/p>\n<p style=\"padding-left: 40px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-23120\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_3.png\" alt=\"\" width=\"598\" height=\"464\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_3.png 598w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_3-300x233.png 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><\/p>\n<p>2) Then, we added a \u2018HTML\u2019 file (with \u2018JavaScript\u2019 code) in the \u2018Iframe\u2019 of Entity Form of <strong>Invoice<\/strong> entity in order to bind \u2018Click Event\u2019 with the \u2018Send Invoice\u2019 button. Please refer below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-23121\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_4.png\" alt=\"\" width=\"1366\" height=\"620\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_4.png 1366w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_4-300x136.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_4-768x349.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_4-1024x465.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_4-660x300.png 660w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<p style=\"padding-left: 40px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-23122\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_5.png\" alt=\"\" width=\"603\" height=\"382\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_5.png 603w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_5-300x190.png 300w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/p>\n<p>3) Next, we added two function (i.e. downloadReport and sendEmailWithAttachment) in our script, as shown below:<\/p>\n<p>\/\/Funtion for downloading reports<\/p>\n<p>downloadReport = function (fileName, format, reportId, regarding, success, failed, scope) {<\/p>\n<p>\/\/\/ &lt;summary&gt;Downloads the MS Dynamics report into a file.&lt;\/summary&gt;<\/p>\n<p>\/\/\/ &lt;param name=&#8221;fileName&#8221; type=&#8221;String&#8221;&gt;A file name for resulting file. Leave &amp;quot;null&amp;quot; to let app to safely generate the file name and extension.&lt;\/param&gt;<\/p>\n<p>\/\/\/ &lt;param name=&#8221;format&#8221; type=&#8221;String&#8221;&gt;One of following formats (must be supported in Dynamics): XML, CSV, PDF, MHTML, EXCELOPENXML, WORDOPENXML, IMAGE.&lt;\/param&gt;<\/p>\n<p>\/\/\/ &lt;param name=&#8221;success&#8221; type=&#8221;function(location)&#8221;&gt;A callback function that is called with the full path to downloaded file.&lt;\/param&gt;<\/p>\n<p>\/\/\/ &lt;param name=&#8221;failed&#8221; type=&#8221;function(errorMsg)&#8221;&gt;A callback which is called in case of error.&lt;\/param&gt;<\/p>\n<p>\/\/\/ &lt;param name=&#8221;scope&#8221; type=&#8221;Object&#8221;&gt;The scope for callbacks.&lt;\/param&gt;<\/p>\n<p>try {<\/p>\n<p>var params = JSON.stringify({<\/p>\n<p>format: format || &#8220;PDF&#8221;,<\/p>\n<p>outputFileName: fileName,<\/p>\n<p>outputFolder: this.outputFolder,<\/p>\n<p>outputFilePath: this.outputFilePath, \/\/ for internal use only<\/p>\n<p>reportId: reportId,<\/p>\n<p>regardingEntity: regarding ? regarding.entityName : null,<\/p>\n<p>regardingId: regarding ? regarding.id : null<\/p>\n<p>});<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/command for downloading report<\/p>\n<p>MobileCRM.bridge.command(&#8220;downloadReport&#8221;, params, success, failed, scope);<\/p>\n<p>} catch (e) {<\/p>\n<p>MobileCRM.bridge.alert(&#8220;An Error Has occurred &#8221; + e);<\/p>\n<p>}<\/p>\n<p>};<\/p>\n<p>\/\/Funtion for sending email<\/p>\n<p>sendEmailWithAttachment = function (filePath, refInvoice) {<\/p>\n<p>try {<\/p>\n<p>\/\/\/ &lt;summary&gt;Sends an email&lt;\/summary&gt;<\/p>\n<p>\/\/\/ &lt;param name=&#8221;filePath&#8221; type=&#8221;String&#8221;&gt; A path of the resulting file&lt;\/param&gt;<\/p>\n<p>\/\/\/ &lt;param name=&#8221;entity&#8221; type=&#8221;MobileCRM.Reference&#8221;&gt;The related entity reference.&lt;\/param&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>var attachments = [];\u00a0 \/\/\/ Array of attachments to send. Element must be a full path or a reference to a note.<\/p>\n<p>attachments.push(filePath);<\/p>\n<p>&nbsp;<\/p>\n<p>MobileCRM.Platform.emailWithAttachments(<\/p>\n<p>&#8220;#####@#######.onmicrosoft.com&#8221;, \/\/\/ email address<\/p>\n<p>&#8220;Invoice&#8221;,\u00a0 \/\/\/ email subject<\/p>\n<p>&#8220;\\nHi,\\n\\n Please Find Attached Invoice. \\n\\n Regards.\\n Kabir&#8221;,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/\/ email body<\/p>\n<p>attachments,<\/p>\n<p>refInvoice, null,<\/p>\n<p>function (error) {<\/p>\n<p>_resultingReport = null;<\/p>\n<p>MobileCRM.bridge.alert(error.message);<\/p>\n<p>}, null);<\/p>\n<p>} catch (e) {<\/p>\n<p>MobileCRM.bridge.alert(&#8220;An Error Has occurred &#8221; + e);<\/p>\n<p>}<br \/>\n};<\/p>\n<p>4) And then used these functions in the \u2018MobileCRM.UI.EntityForm.onCommand\u2019 event, as shown below:<\/p>\n<p>UI.EntityForm.onCommand(&#8220;custom_SendInvoice&#8221;,<\/p>\n<p>function (EntityForm) {<\/p>\n<p>_entInvoice = EntityForm;<\/p>\n<p>try {<\/p>\n<p>_refInvoice = new MobileCRM.Reference(EntityForm.entity.entityName, EntityForm.entity.id, EntityForm.entity.primaryName);<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>downloadReport(&#8220;&#8221;, &#8220;pdf&#8221;, &#8220;32C85C59-7D04-E711-80E6-00155DB8652A&#8221;, _refInvoice,<\/p>\n<p>function (result) {<\/p>\n<p>MobileCRM.bridge.alert(&#8220;Report Downloaded Successfully!&#8221;);<\/p>\n<p>_resultingReport = result;<\/p>\n<p>if (_resultingReport != null) {<\/p>\n<p>\/\/This function sents email with attached report<\/p>\n<p>sendEmailWithAttachment(_resultingReport, _refInvoice);<\/p>\n<p>}<\/p>\n<p>},<\/p>\n<p>function (error) {<\/p>\n<p>_resultingReport = null;<\/p>\n<p>MobileCRM.bridge.alert(error.message);<\/p>\n<p>&nbsp;<\/p>\n<p>});<\/p>\n<p>}<\/p>\n<p>} catch (e) {<\/p>\n<p>MobileCRM.bridge.alert(&#8220;An Error Has occurred &#8221; + e);<\/p>\n<p>}<\/p>\n<p>});<\/p>\n<p>5) Next, we published the Resco Mobile Project and synced the Resco Mobile App with the same. And then navigated to the <strong>Invoice<\/strong> record and clicked on the \u2018Send Invoice\u2019 button (i.e. Custom Command). Please refer below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-23123\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_6.png\" alt=\"\" width=\"1366\" height=\"699\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_6.png 1366w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_6-300x154.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_6-768x393.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_6-1024x524.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_6-660x338.png 660w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<p>6) After the button is clicked, the email window is displayed with \u2018Invoice Report\u2019 added to the email as an attachment. Please refer below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-23124\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_7.png\" alt=\"\" width=\"1366\" height=\"706\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_7.png 1366w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_7-300x155.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_7-768x397.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_7-1024x529.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_7-660x341.png 660w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-23125\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_8.png\" alt=\"\" width=\"1366\" height=\"703\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_8.png 1366w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_8-300x154.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_8-768x395.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_8-1024x527.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_8-660x340.png 660w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<p>7) Next, \u2018Send\u2019 button was clicked and the Email with Attachment was sent to the recipient. Please refer below screenshot:<\/p>\n<p style=\"padding-left: 40px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-23126\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_9.png\" alt=\"\" width=\"801\" height=\"453\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_9.png 801w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_9-300x170.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_9-768x434.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/03\/Blog_9-660x373.png 660w\" sizes=\"(max-width: 801px) 100vw, 801px\" \/><\/p>\n<p><strong><em>Notes: <\/em><\/strong><\/p>\n<ul>\n<li><strong><em>In order to send the Email from Resco Mobile App, we need to configure \u2018Online Exchange\u2019 (i.e. Outlook) in the Resco Mobile Project<\/em><\/strong><\/li>\n<li><strong><em>While using \u2018Offline Mode\u2019, we need to sync the Resco Mobile App after clicking the \u2018Send\u2019 button in order to send an email to the recipient<\/em><\/strong><\/li>\n<li><strong><em>We need to make sure that the Dynamics 365 CRM Reports are enabled for Resco Mobile App in the organization<\/em><\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Conclusion:<\/strong><br \/>\nIn this way, technicians can use the \u2018Send Email\u2019 functionality in order to send emails with an attached report (such as invoice) through Resco Mobile App while working on a job at the client-side.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Recently we had a business requirement, where we needed to send Dynamics 365 CRM Report through Email from Resco Mobile App. In this blog, you will see how to do the same. To achieve this, \u00a0follow the steps given below: 1) We added a custom button (i.e.Command) on the Entity Form of the Invoice\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2020\/03\/how-to-send-email-with-attached-dynamics-365-crm-report-in-resco-mobile-app\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":23136,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[48],"tags":[1447],"class_list":["post-23116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-resco-mobile-crm","tag-resco-mobile-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/23116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=23116"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/23116\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/23136"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=23116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=23116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=23116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}