{"id":21322,"date":"2019-12-06T06:28:49","date_gmt":"2019-12-06T06:28:49","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=21322"},"modified":"2019-12-06T06:28:49","modified_gmt":"2019-12-06T06:28:49","slug":"capture-video-in-dynamics-365-mobile-app-using-client-api-method","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2019\/12\/capture-video-in-dynamics-365-mobile-app-using-client-api-method\/","title":{"rendered":"Capture Video in Dynamics 365 Mobile App Using Client API Method"},"content":{"rendered":"<h3><strong>Introduction<\/strong><\/h3>\n<p>Microsoft has introduced many client APIs for user-friendliness and user attraction. \u2018captureVideo\u2019 is a client API for Dynamics 365 Mobile App in which we can capture a video using mobile device camera and store the captured video. This API is available for Mobile App.<\/p>\n<blockquote><p><strong><em>Note: This API invokes the device camera to record video.<\/em><\/strong><\/p><\/blockquote>\n<p><strong>Syntax: <\/strong><\/p>\n<p>Xrm.Device.captureVideo().then(successCallback, errorCallback)<\/p>\n<p><strong>successCallback:<\/strong> This function gets triggered when video is recorded successfully and returns captured video object. Result object contains following attributes:<\/p>\n<p><strong>fileContent<\/strong>: Contents of the Video file. String<br \/>\n<strong>fileName<\/strong>: Name of the Video file. String.<br \/>\n<strong>fileSize<\/strong>: Size of the Video file in KB. Number.<br \/>\n<strong>mimeType<\/strong>: Video file MIME type. String.<\/p>\n<p><strong>\u00a0errorCallback:<\/strong> This function is called when there is any error in returning the result value. It returns an error object in string format.<\/p>\n<p>For sample purpose we have added <strong>&#8216;Capture Video&#8217;<\/strong>\u00a0button on <strong>Product<\/strong> entity to record video. This button triggers <strong>captureVideo() <\/strong>function. In this function we have used below code:<\/p>\n<pre class=\"lang:default decode:true \">function CaptureVideo(executionContext) {\r\n\r\nvar functionName = \"CaptureVideo\";\r\n\r\nvar productID = null;\r\n\r\nvar formContext = executionContext.getFormContext();\r\n\r\ntry {\r\n\r\n\/\/get current record ID\r\n\r\nproductID = formContext.data.entity.getId();\r\n\r\n\/\/Trigger capture video\r\n\r\nXrm.Device.captureVideo().then(\r\n\r\nfunction successCall(result) {\r\n\r\n\/\/Create annotation object\r\n\r\nvar annotation = {};\r\n\r\nannotation[\"objectid_product@odata.bind\"] = \"\/products(\" + productID.replace('{', '').replace('}', '') + \")\";\r\n\r\nannotation[\"subject\"] = \"Capture Video Using Client API\";\r\n\r\nannotation[\"notetext\"] = \"This video is capture using Client API\";\r\n\r\nannotation[\"filename\"] = result.fileName;\r\n\r\nannotation[\"documentbody\"] = result.fileContent;\r\n\r\nannotation[\"mimetype\"] = result.mimeType;\r\n\r\nannotation[\"filesize\"] = result.fileSize;\r\n\r\n\/\/Create annotation\r\n\r\nXrm.WebApi.createRecord(\"annotation\", annotation, function () {\r\n\r\nXrm.Navigation.openAlertDialog({ confirmButtonLabel: \"OK\", text: \"Record Created Successfully...\" });\r\n\r\n},\r\n\r\nfunction (error) {\r\n\r\n\/\/Show error in alert\r\n\r\nXrm.Navigation.openAlertDialog({ confirmButtonLabel: \"OK\", text: \"Error :: \" + result.message });\r\n\r\n});\r\n\r\n},\r\n\r\nfunction errorCall(result) {\r\n\r\n\/\/Show error in alert\r\n\r\nXrm.Navigation.openAlertDialog({ confirmButtonLabel: \"OK\", text: \"Error :: \" + result });\r\n\r\n});\r\n\r\n} catch (ex) {\r\n\r\nXrm.Navigation.openAlertDialog({ confirmButtonLabel: \"OK\", text: functionName + \" :: \" + ex.message });\r\n\r\n}\r\n\r\n}<\/pre>\n<p>Here, we are storing recorded video in Notes attachment of entity<strong> Product<\/strong>. So, as per above example, when user clicks on<strong> &#8216;Capture Video&#8217;<\/strong> button then above function gets triggered and mobile device camera gets opened automatically to record video. Once user records and saves the video, it will then get stored as Notes attachment of <strong>Product<\/strong> entity.<\/p>\n<blockquote><p><strong><em>Note: Once you save recorded video, you may receive the error \u201cThis feature is disabled in Mobile Settings\u201d as shown below.<\/em><\/strong><\/p><\/blockquote>\n<p style=\"padding-left: 160px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-21324\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/1Dynamics-365-Mobile-App-Using-Client-APIs.png\" alt=\"Dynamics 365 Mobile App Using Client APIs\" width=\"306\" height=\"557\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/1Dynamics-365-Mobile-App-Using-Client-APIs.png 306w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/1Dynamics-365-Mobile-App-Using-Client-APIs-165x300.png 165w\" sizes=\"(max-width: 306px) 100vw, 306px\" \/><\/p>\n<p>So, you need to enable this feature in Mobile Settings. Below are the steps to enable this feature:<\/p>\n<p>Navigate to <strong>Settings -&gt;<\/strong><strong> Mobile Settings <\/strong>and then enable <strong>&#8216;Use Content and Location&#8217;<\/strong>\u00a0option as shown below:<\/p>\n<p style=\"padding-left: 160px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-21323\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/2Dynamics-365-Mobile-App-Using-Client-APIs.png\" alt=\"Dynamics 365 Mobile App Using Client APIs\" width=\"307\" height=\"553\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/2Dynamics-365-Mobile-App-Using-Client-APIs.png 307w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/2Dynamics-365-Mobile-App-Using-Client-APIs-167x300.png 167w\" sizes=\"(max-width: 307px) 100vw, 307px\" \/><\/p>\n<p style=\"padding-left: 160px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-21325\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/3Dynamics-365-Mobile-App-Using-Client-APIs.png\" alt=\"Dynamics 365 Mobile App Using Client APIs\" width=\"309\" height=\"554\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/3Dynamics-365-Mobile-App-Using-Client-APIs.png 309w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/3Dynamics-365-Mobile-App-Using-Client-APIs-167x300.png 167w\" sizes=\"(max-width: 309px) 100vw, 309px\" \/><\/p>\n<p>After enabling this setting you will be able to record video successfully.<\/p>\n<h3><strong>Conclusion:<\/strong><\/h3>\n<p>Thus, by using \u2018<strong>captureVideo<\/strong>\u2019 client API user can record videos and store them in Dynamics 365 CRM.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/productivity-apps\/attach-2-dynamics-365-crm-upload-multiple-files-sharepoint-cloud-storage\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-21334\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/1Attach2Dynamics.png\" alt=\"\" width=\"836\" height=\"209\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/1Attach2Dynamics.png 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/1Attach2Dynamics-300x75.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/1Attach2Dynamics-768x192.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/12\/1Attach2Dynamics-660x165.png 660w\" sizes=\"(max-width: 836px) 100vw, 836px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Microsoft has introduced many client APIs for user-friendliness and user attraction. \u2018captureVideo\u2019 is a client API for Dynamics 365 Mobile App in which we can capture a video using mobile device camera and store the captured video. This API is available for Mobile App. Note: This API invokes the device camera to record video.\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2019\/12\/capture-video-in-dynamics-365-mobile-app-using-client-api-method\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":21333,"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":[17,18],"tags":[1979,565],"class_list":["post-21322","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365-mobiles-tablets","category-dynamics-365-v9-2","tag-client-api","tag-dynamics-365-mobile-app"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/21322","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=21322"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/21322\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/21333"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=21322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=21322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=21322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}