{"id":6276,"date":"2017-08-23T17:39:17","date_gmt":"2017-08-23T12:09:17","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=6276"},"modified":"2022-07-21T12:10:11","modified_gmt":"2022-07-21T06:40:11","slug":"send-invite-to-contacts-automatically-for-microsoft-portal-in-dynamics-365","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2017\/08\/send-invite-to-contacts-automatically-for-microsoft-portal-in-dynamics-365\/","title":{"rendered":"Send Invite to Contacts automatically for Microsoft Portal in Dynamics 365"},"content":{"rendered":"<h4 style=\"text-align: justify;\"><strong>Introduction:<\/strong><\/h4>\n<p style=\"text-align: justify;\">After installing\/configuring the Portal for Dynamics 365 online, the first question that comes to our mind is, <strong><em>how will we give the Portal access\/login to contacts?<\/em><\/strong><\/p>\n<p style=\"text-align: justify;\">In this blog, we will discuss few questions related to Portal access.<\/p>\n<p style=\"text-align: justify;\"><strong>Question #1<\/strong><\/p>\n<p style=\"text-align: justify;\"><strong>As a System Administrator\/CRM User, how can we send an invitation to Dynamics CRM contacts in order to provide access to Microsoft Dynamics CRM\/365 Portal?<\/strong><\/p>\n<p style=\"text-align: justify;\">We can send an invitation to Dynamics CRM contacts by following few simple steps.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>1<\/strong>. First, open the <strong><em>Contact<\/em><\/strong> record to which you want to send an invitation.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>2<\/strong>. Then, click on <strong><em>Create Invitation<\/em><\/strong> button to create Invitation record with <strong><em>Invitation Code.<\/em><\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>3<\/strong>. Save the <strong><em>Invitation record.<\/em><\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>4<\/strong>. Now, run the <strong><em>Send Invitation<\/em><\/strong><\/p>\n<p style=\"text-align: justify;\">An email with the invitation link will be sent to the Contact.<\/p>\n<p>Refer the following link to know more about these steps,\u00a0<a href=\"https:\/\/community.adxstudio.com\/products\/adxstudio-portals\/documentation\/configuration-guide\/portal-authentication\/registration-and-invitations\/invitations\/\">https:\/\/community.adxstudio.com\/products\/adxstudio-portals\/documentation\/configuration-guide\/portal-authentication\/registration-and-invitations\/invitations\/<\/a><\/p>\n<p style=\"text-align: justify;\"><strong>Question #2<\/strong><\/p>\n<p style=\"text-align: justify;\"><strong>As a System Administrator\/CRM User, how can we send an invitation automatically when a contact is created in Dynamics CRM in order to provide access to Microsoft Dynamics CRM\/365 Portal?<\/strong><\/p>\n<p style=\"text-align: justify;\">We can achieve this using a combination of manual workflow and workflow assembly. We need to create one workflow which will trigger on the creation of a contact. And then we just need to execute the steps mentioned above through the workflow.<\/p>\n<p style=\"text-align: justify;\">However, generating invitation code is a bit tricky. We have to pass the Invitation code (which is unique for invitations) along with the invitation link.<\/p>\n<p style=\"text-align: justify;\">Below is the screenshot of the workflow and explanation for each step;<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/08\/Send-Invite-to-Contacts-automatically-for-Microsoft-Portal-in-Dynamics-365.png\"><img decoding=\"async\" class=\"wp-image-6275 size-full aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/08\/Send-Invite-to-Contacts-automatically-for-Microsoft-Portal-in-Dynamics-365.png\" alt=\"Send Invite to Contacts automatically for Microsoft Portal in Dynamics 365\" width=\"498\" height=\"185\" \/><\/a><strong>1. Create an Invitation Code:<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">We have to call the workflow assembly that returns an auto-generated Invitation code as an output parameter.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">Code that generates the invitation code (This is the same logic of generating invitation code as in OOB Invitation process.)<\/p>\n<pre class=\"lang:default decode:true \">\/\/\/ &lt;summary&gt;\r\n    \/\/\/ This assembly will return a randomly generated invitation code\r\n    \/\/\/ &lt;\/summary&gt;\r\n    public class CreateInvitationCode : CodeActivity\r\n    {\r\n        [Output(\"Invitation Code\")]\r\n        public OutArgument&lt;string&gt; InvitationCode { get; set; }\r\n\r\n        \/\/\/ &lt;summary&gt;\r\n        \/\/\/ Execute the process and generate the code\r\n        \/\/\/ &lt;\/summary&gt;\r\n        \/\/\/ &lt;param name=\"context\"&gt;&lt;\/param&gt;\r\n        protected override void Execute(CodeActivityContext codeactivitycontext)\r\n        {\r\n            #region (*Services &amp; Context*)\r\n\r\n            \/\/Create Tracing Service\r\n            ITracingService tracingservice = codeactivitycontext.GetExtension&lt;ITracingService&gt;();\r\n\r\n            \/\/Create the Workflow Context\r\n            IWorkflowContext workflowcontext = codeactivitycontext.GetExtension&lt;IWorkflowContext&gt;();\r\n\r\n            \/\/Service Factory\r\n            IOrganizationServiceFactory organizationservicefactory = codeactivitycontext.GetExtension&lt;IOrganizationServiceFactory&gt;();\r\n\r\n            \/\/Create the Organization Service\r\n            IOrganizationService organizationservice = organizationservicefactory.CreateOrganizationService(workflowcontext.UserId);\r\n\r\n            \/\/Organization Context\r\n            OrganizationServiceContext context = new OrganizationServiceContext(organizationservice);\r\n\r\n            #endregion\r\n            try\r\n            {\r\n                \/\/create the code\r\n                string code = string.Empty;\/\/ GetCodePartition() + GetCodePartition() + GetCodePartition() + GetCodePartition() + GetCodePartition() + GetCodePartition() + GetCodePartition() + GetCodePartition();\r\n\r\n                \/\/Declare random class to randomly generate a number between 0and 1\r\n                Random rnd = new Random();\r\n\r\n                \/\/call the GetCodePartition() 8 times to create the code\r\n                for (int index = 0; index &lt; 8; index++)\r\n                {\r\n                    code += GetCodePartition(rnd);\r\n                }\r\n                \/\/check if code has value\r\n                if (code != string.Empty &amp;&amp; code != null)\r\n                {\r\n                    tracingservice.Trace(\"Code: \" + code);\r\n                    \/\/set the value in output parameter\r\n                    this.InvitationCode.Set(codeactivitycontext, code.Trim().ToLower());\r\n                }\r\n            }\r\n            catch (InvalidPluginExecutionException ex)\r\n            {\r\n                throw new InvalidPluginExecutionException(\"Execute\" + ex.Message);\r\n            }\r\n        }\r\n\r\n        \/\/\/ &lt;summary&gt;\r\n        \/\/\/ Generate code partitions\r\n        \/\/\/ &lt;\/summary&gt;\r\n        \/\/\/ &lt;returns&gt;&lt;\/returns&gt;\r\n        private string GetCodePartition(Random rnd)\r\n        {\r\n            try\r\n            {\r\n                #region(Original function used in JScript)\r\n\r\n                \/\/  return Math.floor((1 + Math.random()) * 0x10000)\r\n                \/\/.toString(16)\r\n                \/\/.substring(1);\r\n\r\n                #endregion\r\n\r\n                \/\/Create an integer number and then convert it to hexadecimal string\r\n                string codePart = Convert.ToInt32(Math.Floor((1 + rnd.NextDouble()) * 65536)).ToString(\"X\").Substring(1);\r\n                return codePart;\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                throw new InvalidPluginExecutionException(\"getCodePartition\" + ex.Message);\r\n            }\r\n        }\r\n    }\r\n<\/pre>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>2<\/strong>.\u00a0<strong>Create an Invitation Record:<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">This workflow step will CREATE an Invitation entity record. Set the output parameter returned by Step 1 in the Invitation code. Then set the other required fields; <strong><em>Sender, Name, Type, Invite Contact, Assign to Account, etc.<\/em><\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>3<\/strong>.\u00a0<strong>Call child workflow that runs for Invitation entity:<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">This workflow will create and send an invitation link. Below is the screenshot of the child Workflow;<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/08\/Send-Invite-to-Contacts-automatically-for-Microsoft-Portal-in-Dynamics-365-1.png\"><img decoding=\"async\" class=\"wp-image-6273 size-full aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/08\/Send-Invite-to-Contacts-automatically-for-Microsoft-Portal-in-Dynamics-365-1.png\" alt=\"Send Invite to Contacts automatically for Microsoft Portal in Dynamics 365 1\" width=\"313\" height=\"137\" \/><\/a><strong>a) Create Email:<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">This step creates an email record where we need to add an invitation link in the email body. Append the invitation code that we generated and saved on the Invitation record, at the end of portal invitation URL.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/08\/Send-Invite-to-Contacts-automatically-for-Microsoft-Portal-in-Dynamics-365-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-6274 aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/08\/Send-Invite-to-Contacts-automatically-for-Microsoft-Portal-in-Dynamics-365-2.jpg\" alt=\"Send Invite to Contacts automatically for Microsoft Portal in Dynamics 365\" width=\"624\" height=\"298\" \/><\/a><strong>b) Call \u2018Portals: Send Invitation\u2019 assembly:<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">Call Microsoft Portal\u2019s <strong><em>\u2018Send Invitation\u2019<\/em><\/strong> custom workflow assembly that sends the email created above to invitees.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>c) Update status of invitation record to Invitation sent:<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">The next step is to update the <strong><em>Invitation Record<\/em><\/strong> to set <strong><em>status reason<\/em><\/strong> as <strong><em>Sent<\/em><\/strong>.<\/p>\n<p style=\"padding-left: 30px; text-align: justify;\"><strong>4. Stop workflow:<\/strong><\/p>\n<p style=\"padding-left: 30px; text-align: justify;\">The final step is to stop the workflow.<\/p>\n<p style=\"text-align: justify;\">Hope this helps!<\/p>\n<h2 style=\"text-align: left;\"><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:15px;margin-bottom:5px\"><div class=\"su-heading-inner\">70% of global 2000 companies apply gamification to improve productivity and returns!<\/div><\/div><\/h2>\n<p><em><strong><a href=\"https:\/\/bit.ly\/3RD4lYW\" target=\"_blank\" rel=\"noopener noreferrer\">Gamifics365<\/a> <\/strong>\u2013 Spin the magic of games within Microsoft Dynamics 365 CRM to improve user adoption, enhance productivity, and achieve company goals!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: After installing\/configuring the Portal for Dynamics 365 online, the first question that comes to our mind is, how will we give the Portal access\/login to contacts? In this blog, we will discuss few questions related to Portal access. Question #1 As a System Administrator\/CRM User, how can we send an invitation to Dynamics CRM\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2017\/08\/send-invite-to-contacts-automatically-for-microsoft-portal-in-dynamics-365\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":6272,"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,19,37,2053],"tags":[1167,1168,1574],"class_list":["post-6276","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-dynamics-crm","category-microsoft-portals","category-power-apps-portals","tag-microsoft-portal-in-dynamics-365","tag-microsoft-portal-in-dynamics-crm","tag-send-invite-to-contacts-dynamics-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/6276","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=6276"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/6276\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/6272"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=6276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=6276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=6276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}