{"id":4374,"date":"2017-01-27T18:35:20","date_gmt":"2017-01-27T13:05:20","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=4374"},"modified":"2017-01-27T18:35:20","modified_gmt":"2017-01-27T13:05:20","slug":"sort-activities-by-custom-date-fields-on-the-socialactivity-pane","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2017\/01\/sort-activities-by-custom-date-fields-on-the-socialactivity-pane\/","title":{"rendered":"Sort Activities by Custom Date fields on the Social\/Activity Pane"},"content":{"rendered":"<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"wp-image-4376\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Sort-Date-by-Custom-Date-Fields.png\" alt=\"Sort Date by Custom Date Fields\" width=\"812\" height=\"406\" \/><\/p>\n<p style=\"text-align: justify;\"><strong>Introduction:<\/strong><\/p>\n<p style=\"text-align: justify;\">Dynamics 365 added a new \u201cSort Date\u201d field (attribute) in Activity entity. With the addition of this new attribute, we can now set the Sort Date field as per customer requirement.<\/p>\n<p style=\"text-align: justify;\">You can now <a href=\"https:\/\/www.inogic.com\/blog\/2016\/12\/sort-social-pane-activities-in-dynamics-365\/\" target=\"_blank\" rel=\"noopener noreferrer\">sort the activities on social pane<\/a> in Dynamics 365. However, the fields shown there are only the ones present on the activity pointer. We cannot add custom field to the activity pointer.<\/p>\n<p style=\"text-align: justify;\">Suppose if we have a requirement where we want to sort activities based on custom field then \u201cSort Date\u201d field is the best option to fulfil this need.<\/p>\n<p style=\"text-align: justify;\"><strong>Where and how to use Sort Date field?<\/strong><\/p>\n<p style=\"text-align: justify;\">For example, we have a requirement where we want to sort our activities as per their approval date. The approval date is a custom field added to the \u201cTask\u201d entity.<\/p>\n<p style=\"text-align: justify;\">To ensure that the tasks are listed on the social pane sorted by \u201cApproval date\u201d, we can set the Sort Date field with the approval date through a quick customization. We can set this field by using business rule, plug-in or writing a script.<\/p>\n<p style=\"text-align: justify;\"><strong>Setting Sort Date field by writing a Script: <\/strong><\/p>\n<p style=\"text-align: justify;\">We can add our script on the Task Approval Date field. Therefore, when the approval date changes, it will trigger the script and set the Sort Date as approval date.<\/p>\n<pre class=\"lang:default decode:true \">function ApprovalDate_OnChange() {\n    var functionName = \"ApprovalDate_OnChange\";\n\n    try {\n         \/\/Get Task activity Approval date\n        var approvalDate = Xrm.Page.getAttribute(\"new_approvaldate\").getValue();\n\n        \/\/check if Approval date is not null \n        if (approvalDate != null &amp;&amp; approvalDate != undefined) {\n\n            \/\/Set Sort Date field as approval date\n            Xrm.Page.getAttribute(\"sortdate\").setValue(approvalDate);\n        }\n    } catch (e) {\n        throw e;\n    }\n}<\/pre>\n<p style=\"text-align: justify;\"><strong>Setting Sort Date field by using Business Rule:<\/strong><\/p>\n<p style=\"text-align: justify;\">We can set the Sort Date field using business rule as shown in below screenshot.<\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-4372\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Sort-Activities-by-Custom-Date-fields-on-the-SocialActivity-Pane1-1024x471.jpg\" alt=\"Sort Activities by Custom Date fields on the SocialActivity Pane-Dynamics CRM\" width=\"665\" height=\"305\" \/><\/p>\n<p style=\"text-align: justify;\">Note: Since the custom field was added only on the Task entity, you will need to add a custom business rule for all other activities to populate the Sort Date field with the value appropriate for those activity types.<\/p>\n<p style=\"text-align: justify;\">With the Sort date now set for all the activity types, we can use this field in Activity Pane for sorting the activities as per the criteria we have set.<\/p>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"aligncenter  wp-image-4373\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Sort-Activities-by-Custom-Date-fields-on-the-SocialActivity-Pane2.jpg\" alt=\"Sort Activities by Custom Date fields on the SocialActivity Pane-Dynamics CRM\" width=\"646\" height=\"344\" \/><\/p>\n<p style=\"text-align: justify;\"><strong>Conclusion:<\/strong><\/p>\n<p style=\"text-align: justify;\">Use the Sort Date field on the ActivityPointer to sort your activities by custom date fields on activities.<\/p>\n<p style=\"text-align: justify;\"><a title=\"Maplytics Jan 2017 Release Coming \u2013 We speak your language!\" href=\"https:\/\/www.inogic.com\/blog\/2017\/01\/maplytics-jan-2017-release-coming-we-speak-your-language\/\" target=\"_blank\" rel=\"noopener noreferrer\">Spanish, German, French, Portuguese, and Turkish \u2013 Map analytics within Dynamics 365\/CRM now in language of your choice!\u00a0<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Dynamics 365 added a new \u201cSort Date\u201d field (attribute) in Activity entity. With the addition of this new attribute, we can now set the Sort Date field as per customer requirement. You can now sort the activities on social pane in Dynamics 365. However, the fields shown there are only the ones present on\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2017\/01\/sort-activities-by-custom-date-fields-on-the-socialactivity-pane\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":4380,"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":[16,56],"tags":[91,92,1635,1636],"class_list":["post-4374","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-social-pane","tag-activity-pane-sorting-dynamics-365","tag-activity-pane-sorting-dynamics-crm","tag-social-paneactivity-pane-sorting-dynamics-365","tag-social-paneactivity-pane-sorting-dynamics-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/4374","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=4374"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/4374\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/4380"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=4374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=4374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=4374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}