{"id":1883,"date":"2007-08-09T05:27:00","date_gmt":"2007-08-09T05:27:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/cesardelatorre\/2007\/08\/09\/crm-4-0-titan-server-side-programming-creating-custom-aspx-pages-and-consuming-titans-web-services\/"},"modified":"2007-08-09T05:27:00","modified_gmt":"2007-08-09T05:27:00","slug":"crm-4-0-titan-server-side-programming-creating-custom-aspx-pages-and-consuming-titans-web-services","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/crm-4-0-titan-server-side-programming-creating-custom-aspx-pages-and-consuming-titans-web-services\/","title":{"rendered":"CRM 4.0 (Titan) Server-Side programming: Creating custom ASPX pages and consuming Titan&#8217;s Web-Services"},"content":{"rendered":"<p><P><SPAN lang=\"EN-US\">I&#8217;m doing several <STRONG>Titan<\/STRONG> labs (CRM 4.0 labs), so&nbsp;I&#8217;m going to write a posting about what I&#8217;m doing. It is always interesting archiving this kind of &#8216;HOW TOs&#8217;.&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">So!, I&#8217;m gonna create a plain new custom ASPX page (using Visual Studio 2005) where we&#8217;re going to allow updates to several custom entities I&#8217;ve got.<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">The business purpose for this page would be allowing week &amp; hours for time entry related to projects, etc. The business purpose is not the important point in this case. What I want to show is how to create a custom ASPX that access and updates into CRM-Titan.<\/SPAN><\/P>\n<P><STRONG><SPAN lang=\"EN-US\">First step: Creating the ASPX Page<\/SPAN><\/STRONG><SPAN lang=\"EN-US\"><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">In order to&nbsp;create an ASPX page, we open VS.2005 and we create a new Web-Site (normal stuff in VS.2005). I prefer doing it in C#. <\/SPAN><SPAN><SPAN>J<\/SPAN><\/SPAN><SPAN lang=\"EN-US\"><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">So, within the \u2018default.aspx\u2019 page we add two combo-boxes, one for companies and another one for projects. We also add a Table, and within that table we add several labels and textbox controls which represent current week and hours for time entry. <SPAN>&nbsp;<\/SPAN><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">The ASPX design-time (in <STRONG>Visual Studio 2005<\/STRONG>) would be something similar to the following:<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><IMG height=\"401\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/2007_08_09__01_VS2005_Page.jpg\" width=\"570\"><\/SPAN><\/P><SPAN lang=\"EN-US\">\n<P><SPAN lang=\"EN-US\">And the HTML and Web-controls tags (ASPX code) would be something like:<\/SPAN><\/P>\n<P>\n<TABLE class=\"MsoTableGrid\" cellSpacing=\"0\" cellPadding=\"0\" border=\"1\">\n<TBODY>\n<TR>\n<TD class=\"\" vAlign=\"top\" width=\"576\">\n<P><SPAN lang=\"EN-US\">&lt;%@ Page Language=&#8221;C#&#8221; AutoEventWireup=&#8221;true&#8221;<SPAN>&nbsp; <\/SPAN>CodeFile=&#8221;Default.aspx.cs&#8221; Inherits=&#8221;_Default&#8221; %&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&#8221;&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221; &gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&lt;head runat=&#8221;server&#8221;&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;title&gt;CDLTLL &#8211; My custom ASPX page&lt;\/title&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&lt;\/head&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&lt;body&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;div&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:Label ID=&#8221;Label1&#8243; runat=&#8221;server&#8221; Font-Bold=&#8221;True&#8221; Text=&#8221;Organizations&#8221;&gt;&lt;\/asp:Label&gt;&lt;br \/&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:DropDownList ID=&#8221;ddlOrganizations&#8221; runat=&#8221;server&#8221; Width=&#8221;200px&#8221;&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;\/asp:DropDownList&gt;&lt;br \/&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;br \/&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:Label ID=&#8221;Label2&#8243; runat=&#8221;server&#8221; Font-Bold=&#8221;True&#8221; Text=&#8221;Projects&#8221;&gt;&lt;\/asp:Label&gt;&lt;br \/&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:DropDownList ID=&#8221;ddlProjects&#8221; runat=&#8221;server&#8221; Width=&#8221;200px&#8221;&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;\/asp:DropDownList&gt;&lt;br \/&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;br \/&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:Table ID=&#8221;tblTimeEntries&#8221; runat=&#8221;server&#8221;&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableRow ID=&#8221;TableRow1&#8243; runat=&#8221;server&#8221;&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell ID=&#8221;Mon&#8221; runat=&#8221;server&#8221;&gt;&lt;\/asp:TableCell&gt; <\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;<\/SPAN><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell ID=&#8221;Tue&#8221; runat=&#8221;server&#8221;&gt;&lt;\/asp:TableCell&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell ID=&#8221;Wed&#8221; runat=&#8221;server&#8221;&gt;&lt;\/asp:TableCell&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell ID=&#8221;Thu&#8221; runat=&#8221;server&#8221;&gt;&lt;\/asp:TableCell&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell ID=&#8221;Fri&#8221; runat=&#8221;server&#8221;&gt;&lt;\/asp:TableCell&gt;<SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;\/asp:TableRow&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableRow ID=&#8221;TableRow2&#8243; runat=&#8221;server&#8221;&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell&gt;&lt;asp:TextBox ID=&#8221;Mon_Hours&#8221; runat=&#8221;server&#8221; Width=&#8221;20&#8243;&gt;&lt;\/asp:TextBox&gt;&lt;\/asp:TableCell&gt; <\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN>&lt;asp:TableCell&gt;&lt;asp:TextBox ID=&#8221;Tue_Hours&#8221; runat=&#8221;server&#8221; Width=&#8221;20&#8243;&gt;&lt;\/asp:TextBox&gt;&lt;\/asp:TableCell&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell&gt;&lt;asp:TextBox ID=&#8221;Wed_Hours&#8221; runat=&#8221;server&#8221; Width=&#8221;20&#8243;&gt;&lt;\/asp:TextBox&gt;&lt;\/asp:TableCell&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell&gt;&lt;asp:TextBox ID=&#8221;Thu_Hours&#8221; runat=&#8221;server&#8221; Width=&#8221;20&#8243;&gt;&lt;\/asp:TextBox&gt;&lt;\/asp:TableCell&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:TableCell&gt;&lt;asp:TextBox ID=&#8221;Fri_Hours&#8221; runat=&#8221;server&#8221; Width=&#8221;20&#8243;&gt;&lt;\/asp:TextBox&gt;&lt;\/asp:TableCell&gt;<SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;\/asp:TableRow&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;\/asp:Table&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&amp;nbsp;&amp;nbsp;&lt;br \/&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;asp:Button ID=&#8221;btnOK&#8221; runat=&#8221;server&#8221; Text=&#8221;OK&#8221; \/&gt;&lt;\/div&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp; <\/SPAN>&lt;\/form&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&lt;\/body&gt;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&lt;\/html&gt;<\/SPAN><SPAN lang=\"EN-US\"><\/SPAN><\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/P>\n<P><SPAN lang=\"EN-US\">So far, this is plain ASPX code, nothing about CRM-Titan, yet.<\/SPAN><\/P>\n<P><STRONG><SPAN lang=\"EN-US\">Second step: Adding CRM-Titan Web-Service References<\/SPAN><\/STRONG><SPAN lang=\"EN-US\"><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">No we start the fun part, let\u2019s add some CRM-Titan Web-References into our WebSite project!! <\/SPAN><SPAN lang=\"EN-US\"><SPAN>J<\/SPAN><\/SPAN><SPAN lang=\"EN-US\"><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">OK, first, we add a web reference to the CrmDiscoveryService (the one with AD authentication, there is another one for Passport authentication aa well as SPLA for custom forms authentication), so the URL we have to use is the following:<\/SPAN><\/P>\n<P>\n<TABLE class=\"MsoTableGrid\" cellSpacing=\"0\" cellPadding=\"0\" border=\"1\">\n<TBODY>\n<TR>\n<TD class=\"\" vAlign=\"top\" width=\"576\">\n<P><SPAN lang=\"EN-US\">http:\/\/localhost:5555\/MSCRMServices\/2007\/AD\/CrmDiscoveryService.asmx<\/SPAN><\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/P>\n<P><SPAN lang=\"EN-US\">The \u2018Add Web Reference\u2019 window would be like:<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><\/SPAN><IMG src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/2007_08_09__02_WebRefCrmDiscoveryService.jpg\">&nbsp;<\/P>\n<P><SPAN lang=\"EN-US\">So, what is new in this <B>CrmDiscoveryService<\/B>?. Because of CRM-Titan provides now Multi-Tenancy (Multi-Tenancy: A single CRM server could be servicing multiple business organizations), before calling the real \u2018data-web-service\u2019, we need to know which web-service we have to use. I mean, since each CRM server may be serving a call for a different organization each time, the web services must be notified of the target organization a user is intending to reach. So this <B>CrmDiscoveryService<\/B> Web-Service allows to query all the CRM organizations on the server as well as instantiate CrmTicket credentials to allow requests for specific organizations.<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">Now, we add another web reference for the updated CrmService, which has the following URL:<\/SPAN><\/P>\n<P>\n<TABLE class=\"MsoTableGrid\" cellSpacing=\"0\" cellPadding=\"0\" border=\"1\">\n<TBODY>\n<TR>\n<TD class=\"\" vAlign=\"top\" width=\"576\">\n<P><SPAN lang=\"EN-US\"><A href=\"http:\/\/localhost:5555\/MSCRMServices\/2007\/CrmServiceWsdl.aspx\">http:\/\/localhost:5555\/MSCRMServices\/2007\/CrmServiceWsdl.aspx<\/A><\/SPAN><\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/P>\n<P><IMG src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/2007_08_09__03_WebRefCrmService.jpg\">&nbsp;<\/P>\n<P><SPAN lang=\"EN-US\">So we have added references to the required CRM-Titan web-services using Windows integrated security for authentication.<\/SPAN><\/P>\n<P><STRONG><SPAN lang=\"EN-US\">Third step: Writing C# Code-Behind accessing Titan\u2019s WebServices<\/SPAN><\/STRONG><SPAN lang=\"EN-US\"><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">Now, we add some C# code within the ASPX page \u2018code-behind\u2019.<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">BTW, whenever you see a prefix like \u2018<\/SPAN><B><SPAN lang=\"EN-US\"><FONT size=\"3\">cdltll_<\/FONT><\/SPAN><\/B><SPAN lang=\"EN-US\">\u2019 into my code, it is the CRM prefix that CRM internally concatenates to every schema name (for columns, entities, etc.). By default, CRM adds the prefix \u2018<\/SPAN><B><SPAN lang=\"EN-US\"><FONT size=\"3\">new_<\/FONT><\/SPAN><\/B><SPAN lang=\"EN-US\">\u2019 but I prefer changing it to my own prefix (<I>From CRM <\/I><\/SPAN><I><SPAN lang=\"EN-US\"><SPAN>\u00e0<\/SPAN><\/SPAN><\/I><I><SPAN lang=\"EN-US\"> Settings <\/SPAN><\/I><I><SPAN lang=\"EN-US\"><SPAN>\u00e0<\/SPAN><\/SPAN><\/I><I><SPAN lang=\"EN-US\"> Org.Settings <\/SPAN><\/I><I><SPAN lang=\"EN-US\"><SPAN>\u00e0<\/SPAN><\/SPAN><\/I><I><SPAN lang=\"EN-US\"> System Settings <\/SPAN><\/I><I><SPAN lang=\"EN-US\"><SPAN>\u00e0<\/SPAN><\/SPAN><\/I><I><SPAN lang=\"EN-US\"> Customization <\/SPAN><\/I><I><SPAN lang=\"EN-US\"><SPAN>\u00e0<\/SPAN><\/SPAN><\/I><I><SPAN lang=\"EN-US\"> Prefix<\/SPAN><\/I><SPAN lang=\"EN-US\">), which could be you company\u2019s initials or in my case, are my own initials (<B>CDLTLL<\/B><\/SPAN><B><SPAN lang=\"EN-US\"><SPAN>\u00e0<\/SPAN><\/SPAN><\/B><B><SPAN lang=\"EN-US\"> Cesar De La Torre Llorente<\/SPAN><\/B><SPAN lang=\"EN-US\">). <\/SPAN><SPAN lang=\"EN-US\"><SPAN>J<\/SPAN><\/SPAN><SPAN lang=\"EN-US\"><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">So!, first interesting code would be when we want to connect and get all the available organizations and loading the that list within the \u2018Organizations\u2019 Combo-box. To do so, we should call the CrmDiscoveryService coding something like the following:<\/SPAN><\/P>\n<P>\n<TABLE class=\"MsoTableGrid\" cellSpacing=\"0\" cellPadding=\"0\" width=\"603\" border=\"1\">\n<TBODY>\n<TR>\n<TD class=\"\" vAlign=\"top\" width=\"603\">\n<P><SPAN lang=\"EN-US\">\/\/Instantiate web-service proxy class<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">CrmDiscoveryService.<B>CrmDiscoveryService<\/B> discoveryService = <\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>new CrmDiscoveryService.CrmDiscoveryService();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\/\/Provide current Windows\/AD Credentials<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">discoveryService.Credentials = System.Net.CredentialCache.DefaultCredentials;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\/\/Configure what we want to request<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">RetrieveOrganizationsRequest orgsRequest = new RetrieveOrganizationsRequest();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\/\/Make request for organization information<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">RetrieveOrganizationsResponse orgsResponse = <\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>(RetrieveOrganizationsResponse)discoveryService.Execute(orgsRequest);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\/\/Loop to populate the organizations<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\u2026<\/SPAN><\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/P>\n<P><SPAN lang=\"EN-US\">Likewise, if we want to get the \u2018project list\u2019 (from my project custom entity), it would be something like:<\/SPAN><\/P>\n<P>\n<TABLE class=\"MsoTableGrid\" cellSpacing=\"0\" cellPadding=\"0\" border=\"1\">\n<TBODY>\n<TR>\n<TD class=\"\" vAlign=\"top\" width=\"576\">\n<P><SPAN lang=\"EN-US\">CrmService.<B>CrmAuthenticationToken<\/B> token = new CrmAuthenticationToken();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">token.OrganizationName = &#8220;My Organization\u2019s Name&#8221;;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">CrmService.<B>CrmService<\/B> crmService = new CrmService.CrmService();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">crmService.Credentials = System.Net.CredentialCache.DefaultCredentials;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">crmService.CrmAuthenticationTokenValue = token;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">QueryByAttribute query = new QueryByAttribute();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">ColumnSet cols = new ColumnSet();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">cols.Attributes = new string[] { &#8220;cdltll_projectid&#8221;, &#8220;cdltll_name&#8221; };<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">query.ColumnSet = cols;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">query.EntityName = EntityName.cdltll_project.ToString();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">query.Attributes = new string[] { &#8220;ownerid&#8221; };<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">WhoAmIRequest userRequest = new WhoAmIRequest();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">WhoAmIResponse user = (WhoAmIResponse)crmService.Execute(userRequest);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\/\/ The logged on users userid<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">query.Values = new object[] { user.UserId.ToString() };<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">BusinessEntityCollection retrievedProjects = crmService.RetrieveMultiple(query);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\/\/Loop to populate the projects<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\u2026<\/SPAN><SPAN lang=\"EN-US\"><\/SPAN><\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/P>\n<P><SPAN lang=\"EN-US\">So, with kind of this code run within my Page_Load() method, I could get data in my ASP.NET page, like you can see down below:<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><IMG src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/2007_08_09__04_ASP_Page_Execution.jpg\">&nbsp;<\/SPAN><\/P><SPAN lang=\"EN-US\">\n<P><SPAN lang=\"EN-US\">Then, we can take the numbers\/hours provided into the timesheet text-boxes (we should type it first, of course. ;-)), and update my custom entity called \u2018<B>Timesheet<\/B>\u2019.<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">Basically, we should write this code for updating against CRM-Titan Web-Service:<\/SPAN><\/P>\n<P>\n<TABLE class=\"MsoTableGrid\" cellSpacing=\"0\" cellPadding=\"0\" border=\"1\">\n<TBODY>\n<TR>\n<TD class=\"\" vAlign=\"top\" width=\"576\">\n<P><SPAN lang=\"EN-US\">\/\/ Instantiate a new timesheet entity<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">cdltll_timesheet timesheet = new cdltll_timesheet();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_datesubmitted = new CrmDateTime();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_datesubmitted.Value = DateTime.Now.ToShortDateString();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day1 = new CrmNumber();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day1.Value = Convert.ToInt32(Mon_Hours.Text);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day2 = new CrmNumber();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day2.Value = Convert.ToInt32(Tue_Hours.Text);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day3 = new CrmNumber();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day3.Value = Convert.ToInt32(Wed_Hours.Text);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day4 = new CrmNumber();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day4.Value = Convert.ToInt32(Thu_Hours.Text);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day5 = new CrmNumber();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_day5.Value = Convert.ToInt32(Fri_Hours.Text);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">\/\/ Set the current weeks Monday<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_startdate = new CrmDateTime();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_projectid = new Lookup();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_projectid.Value = new Guid(ddlProjects.SelectedValue);<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">timesheet.cdltll_name = ddlProjects.SelectedItem.Text + &#8221; &#8211; Timesheet submitted for &#8221; + timesheet.cdltll_startdate.Value.ToString();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><B><SPAN lang=\"EN-US\">\/\/Create de Web-Service objet-proxy<\/SPAN><\/B><\/P>\n<P><SPAN lang=\"EN-US\">CrmService.<B>CrmAuthenticationToken<\/B> token = new CrmAuthenticationToken();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">token.OrganizationName = &#8220;My Organization\u2019s Name&#8221;;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">CrmService.<B>CrmService<\/B> crmService = new CrmService.CrmService();<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">crmService.Credentials = System.Net.CredentialCache.DefaultCredentials;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">crmService.CrmAuthenticationTokenValue = token;<\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\">&nbsp;<\/SPAN><\/P>\n<P><B><SPAN lang=\"EN-US\">\/\/Create\/Update the TimeSheet within CRM-Titan<\/SPAN><\/B><\/P>\n<P><B><SPAN lang=\"EN-US\">Guid timeSheetId = crmService.Create(timesheet);<\/SPAN><\/B><SPAN lang=\"EN-US\"><\/SPAN><\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/P>\n<P><SPAN lang=\"EN-US\">So after updating, let\u2019s say this hours (8,8,8,8,7), if we enter into CRM-Titan client, we can see it already updated!! <\/SPAN><SPAN lang=\"EN-US\"><SPAN>J<\/SPAN><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN><IMG src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/2007_08_09__05_Titan_Client_Check.jpg\"><\/SPAN><\/SPAN><\/P>\n<P><SPAN lang=\"EN-US\"><SPAN><\/SPAN><\/SPAN><SPAN lang=\"EN-US\"><\/SPAN>&nbsp;If anybody wants the whole ASP.NET page and project, just write on&nbsp;a comment&nbsp;on this posting, OK?. \ud83d\ude42<\/P>\n<P>&#8211;&gt; Updated. Due to many requests, I have uploaded the source code within this post. Keep in mind this code was developed while CRM 4.0 was in BETA state. Several points could have changed.<\/P><\/SPAN><\/SPAN><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/32\/2019\/03\/05%20ASP.NET%20Accessing%20CRM4%20Web%20Services.zip\">05 ASP.NET Accessing CRM4 Web Services.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m doing several Titan labs (CRM 4.0 labs), so&nbsp;I&#8217;m going to write a posting about what I&#8217;m doing. It is always interesting archiving this kind of &#8216;HOW TOs&#8217;.&nbsp; So!, I&#8217;m gonna create a plain new custom ASPX page (using Visual Studio 2005) where we&#8217;re going to allow updates to several custom entities I&#8217;ve got. The [&hellip;]<\/p>\n","protected":false},"author":362,"featured_media":12806,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[97],"class_list":["post-1883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cesardelatorre","tag-titan"],"acf":[],"blog_post_summary":"<p>I&#8217;m doing several Titan labs (CRM 4.0 labs), so&nbsp;I&#8217;m going to write a posting about what I&#8217;m doing. It is always interesting archiving this kind of &#8216;HOW TOs&#8217;.&nbsp; So!, I&#8217;m gonna create a plain new custom ASPX page (using Visual Studio 2005) where we&#8217;re going to allow updates to several custom entities I&#8217;ve got. The [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/1883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/comments?post=1883"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/1883\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media\/12806"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media?parent=1883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/categories?post=1883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/tags?post=1883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}