{"id":185,"date":"2022-01-06T11:23:56","date_gmt":"2022-01-06T11:23:56","guid":{"rendered":"https:\/\/blog.citrus-lime.com\/crmc\/?p=185"},"modified":"2022-01-06T11:23:57","modified_gmt":"2022-01-06T11:23:57","slug":"new-records-in-crm-with-pre-populated-values","status":"publish","type":"post","link":"https:\/\/blog.citrus-lime.com\/crmc\/new-records-in-crm-with-pre-populated-values\/","title":{"rendered":"New Records in CRM with Pre-Populated Values"},"content":{"rendered":"\n<p>As Dynamics CRM is a web-based application, we can open various screens by simply providing a URL Link \u2013 so we might provide a Salesperson with a quick link to open a new Opportunity Record via the following:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><a href=\"https:\/\/mycrm.crmcs.co.uk\/main.aspx?etn=opportunity&amp;pagetype=entityrecord\">https:\/\/mycrm.crmcs.co.uk\/main.aspx?<strong>etn=opportunity&amp;pagetype=entityrecord<\/strong><\/a><\/p><\/blockquote>\n\n\n\n<p>Opening this link will then directly browse into the New Opportunity Form which can be a handy time-saving technique as we could then embed this link into an Intranet or Dashboard to make CRM quicker (and so easier) to use for the end user.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_17F1F6A7.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p>However the real strength of this is the ability to not only open the Opportunity but provide a URL Link which pre-populates certain Fields on the Form.<\/p>\n\n\n\n<p>So we might provide a Link that creates a New Opportunity pre-populated to a particular Customer and\/or Opportunity Type.<\/p>\n\n\n\n<p>We can do this adding an additional element to the URL for \u2018extraqs\u2019 \u2013 so if looked at a basic example of pre-populating the Name of the Opportunity:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><a href=\"https:\/\/mycrm.crmcs.co.uk\/main.aspx?etn=opportunity&amp;pagetype=entityrecord&amp;extraqs=name%3DMyOpportunity\">https:\/\/mycrm.crmcs.co.uk\/main.aspx?etn=opportunity&amp;pagetype=entityrecord&amp;<strong>extraqs=name%3DMyOpportunity<\/strong><\/a><\/p><\/blockquote>\n\n\n\n<p>This will then prepopulate the \u2018name\u2019 field with \u2018My Opportunity\u2019.<\/p>\n\n\n\n<p>We can then extend this to include multiple parameters using the same %3D Request String format, alongside separating %26 to separate out the parameters<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><a href=\"https:\/\/mycrm.crmcs.co.uk\/main.aspx?etn=opportunity&amp;pagetype=entityrecord&amp;extraqs=name%3DMyOpportunity%26description%3DExampleDescription\">https:\/\/mycrm.crmcs.co.uk\/main.aspx?etn=opportunity&amp;pagetype=entityrecord&amp;<strong>extraqs=name%3DMyOpportunity<\/strong><strong>%26description%3DExampleDescription<\/strong><\/a><\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_4573166A.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p>Obviously the difficult part here is the %3d and %26 \u2018tagging\u2019 characters to handle breaks in our Parameters \u2013 these are corresponding to the &amp; and = characters within the \u2018extraqs\u2019 parameter itself, but make for a difficult URL when it comes to try to human-read what is going on.<\/p>\n\n\n\n<p>This is using HTML Encoding to handle the \u2018extraqs\u2019 parameter as a part within the wider Request String.&nbsp; The following link gives more context on this ability to Encode a URL using this % notation as way of handling non-standard characters without confusing the Web Browser:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><a href=\"https:\/\/www.w3schools.com\/tags\/ref_urlencode.asp\"><strong>https:\/\/www.w3schools.com\/tags\/ref_urlencode.asp<\/strong><\/a><strong>&nbsp;<\/strong><\/p><\/blockquote>\n\n\n\n<p>Obviously this concept of % characters to replace certain characters does not lead itself to typing up human readable URLs, and so to try and make life easier for ourselves, we can look at using a Spreadsheet Excel Formula to build this link for us:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_37349D7A.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p>This can then use the SUBSTITUTE Excel Formula to encode our Name\/Value Parameters into the right encoding for the URL.<\/p>\n\n\n\n<p>We this freedom, we can look at adding various parameters for our URL and look at how we can add Lookup, Option Set and Custom fields to our URL.<\/p>\n\n\n\n<p>For Option Sets and Custom Fields, this is quite simple as these follow the same format.<\/p>\n\n\n\n<p>For Lookups however, we need to supply the other 2 elements that CRM tracks for each Lookup: the&nbsp;<strong>.Name<\/strong>&nbsp;and&nbsp;<strong>.Type<\/strong>&nbsp;attributes of the Lookup alongside the code&nbsp;<strong>.Id<\/strong>.<\/p>\n\n\n\n<p>So we need to pass our request as&nbsp;<strong>lookupid={xxx-xxx-xxx}&amp;lookupidname=RecordName&amp;lookupidtype=RecordType<\/strong>&nbsp;which adds some complexity when working with Lookup fields \u2013 however we can work this complexity into our Excel Formula to limit our thinking-time here:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_3DE7A6FD.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p>Which then results in passing a more complex set of starting values to our New Opportunity:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_449AB080.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p>Now we have this URL, we can embed this within an Email or Web Page to provide a better User Experience for the End User in potentially giving them a quick link to create a Gap-Fill Opportunity for a particular Customer or with a particular set of starting values.<\/p>\n\n\n\n<p>This is great for a quick static URL, however if we took this principle into a more Web Application point-of-view then we could look at how our Application Code could potentially generate this URL on the fly to give various dynamics URLs at run time for the Entity and Attributes we want \u2013 essentially replacing the Spreadsheet here with our own code-behind logic.<\/p>\n\n\n\n<p>The advantage we have here is that we can use a method in the core .NET Framework to handle the URL Encode for us, instead of relying on an Excel Formula.<\/p>\n\n\n\n<p>\/\/ build our string of useful parameters<\/p>\n\n\n\n<p>string&nbsp;parameterString =&nbsp;&#8220;name=New Business Opportunity&amp;&#8221;;<\/p>\n\n\n\n<p>parameterString +=&nbsp;&#8220;description=Please chase this opportunity and update your notes accordigly&amp;&#8221;;<\/p>\n\n\n\n<p>parameterString +=&nbsp;&#8220;new_businesstype=267040002&amp;&#8221;;<\/p>\n\n\n\n<p>parameterString +=&nbsp;&#8220;customerid={81403A53-6D8C-E511-80BC-00155D05198A}&amp;customeridname=Land and New Homes&amp;customeridtype=account&#8221;;<\/p>\n\n\n\n<p>\/\/ build the end-url<\/p>\n\n\n\n<p>string&nbsp;urlOpenNewFormInCRM =&nbsp;@&#8221;https:\/\/mycrm.crmcs.co.uk\/main.aspx?etn=opportunity&amp;pagetype=entityrecord&amp;extraqs=&#8221;&nbsp;+&nbsp;<strong>Server.UrlEncode(parameterString)<\/strong>;<\/p>\n\n\n\n<p>\/\/ build hyperlink and add into the page<\/p>\n\n\n\n<p>HyperLink&nbsp;linkOpenNewFormInCRM =&nbsp;new&nbsp;HyperLink();<\/p>\n\n\n\n<p>linkOpenNewFormInCRM.NavigateUrl = urlOpenNewFormInCRM;<\/p>\n\n\n\n<p>This gives a more Development-heavy method of achieving the same result as our Formula-based Spreadsheet, which can be handy if developing a custom link to embed in a Webpage, Dashboard or Email.<\/p>\n\n\n\n<p>This ability to provide CRM URL Links that open particular Forms can very useful to tailor the End User Experience and so is embedded throughout CRM \u2013 not just for Entity Forms, but also for Advanced Finds, Views and even allowing entirely different Forms to be opened for an Entity Form. (so we could have a link to open Form Type A for a Record, and a separate link to open Form Type B for a record)<\/p>\n\n\n\n<p>The following article from Microsoft\u2019s MSDN expands on this concept and gives the finer detail on how these URL Links work within Dynamics CRM:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Open Forms, Views, Dialogs and Reports with a URL<\/strong><\/p><p><a href=\"https:\/\/msdn.microsoft.com\/en-gb\/library\/gg328483.aspx\">https:\/\/msdn.microsoft.com\/en-gb\/library\/gg328483.aspx<\/a><\/p><\/blockquote>\n\n\n\n<p>And we can see this first-hand in CRM, as each Form or Views gives us a button for \u2018Email a Link\u2019 which effectively use this functionality to allow Links to certain records to be Emailed through the business using CRM:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_6F731492.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p>The Spreadsheet URL Generator for this article can be downloaded here for future reference:&nbsp;<a href=\"https:\/\/support.crmcs.co.uk\/downloads\/CRMCS_DynamicsCRM_LinkGenerator.xlsx\">https:\/\/support.crmcs.co.uk\/downloads\/CRMCS_DynamicsCRM_LinkGenerator.xlsx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As Dynamics CRM is a web-based application, we can open various screens by simply providing a URL Link \u2013 so we might provide a Salesperson with a quick link to open a new Opportunity Record via the following: https:\/\/mycrm.crmcs.co.uk\/main.aspx?etn=opportunity&amp;pagetype=entityrecord Opening this link will then directly browse into the New Opportunity Form which can be a<\/p>\n","protected":false},"author":43,"featured_media":35,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[3],"tags":[],"class_list":{"0":"post-185","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-crm"},"featured_image_src":"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2021\/11\/Dynamics-365-Consultancy.jpg","author_info":{"display_name":"jadesmith","author_link":"https:\/\/blog.citrus-lime.com\/crmc\/author\/jadesmith\/"},"_links":{"self":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":1,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":186,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/185\/revisions\/186"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media\/35"}],"wp:attachment":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}