|
Creating Web Forms for Oracle CRM On Demand By: Joerg Wallmueller – CRM Pre Sales ANZ Introduction.. 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300350038000000 Requirements. 2 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300350039000000 Step 1: Create a new Service Request Web Site.. 4 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300360030000000 Step 2: Download a WSDL file.. 9 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300360031000000 Step 3: Add WSDL to application.. 10 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300360032000000 Step 4: Add required code to our application.. 10 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300360033000000 Step 5: Define Virtual Directory.. 14 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300360034000000 Conclusion.. 16 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300360035000000 Appendix 1 - Sample code for capturing a lead.. 17 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300360036000000 Appendix 2 – “Server Application Unavailable“ error. 17 08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200330031003200380030003300360037000000 Introduction I was really quite surprised by the amount of positive feedback which I received for my previous whitepaper “Java Access to CRM On Demand.doc”. It proved that a lot of you still love to get their hands “dirty” with some coding from time-to-time. So here is a new whitepaper for you! Typical customer requirements are to capture leads, activities or s in a corporate or customer facing portal, and to pass the information over to CRM OD. This tutorial guides you in setting up an ASP .NET web form to capture s. It will access your CRM On Demand application using the Web Service interface. Any particular programming skills are not required to follow the tutorial, just solid know-how in copy-and-paste! Requirements You will need the following three components: a) IIS (Internet Information Server) 5.0 or higher As this is usually not pre-installed on a typical Oracle image, you need to install it yourself. You can do so by navigating to “Control Panel” à “Add or Remove Programs” à”Add/Remove Windows Components”. Select “Internet Information Services (IIS)” in the dialog and install.  In the case the installation of IIS fails (which can happen due to a bug in Microsoft Service Pack 3) you have the following two options: · Open a iSupport ticket to get IIS installed · Run this tutorial on the Siebel VMWare demo image b) .NET Framework 2.0 or higher Should be pre-installed, but if it isn’t you need to download and install from Microsoft. c) Microsoft Visual Web Developer 2008 Express Edition This can be downloaded for free from http://www.microsoft.com/express/vwd/#webInstall. Simply follow a standard installation. Step 1: Create a new Service Request Web Site First we are going to create a new web site in Microsoft Visual Web Developer (MSVWD). After the start-up of MSVWD, click the link “Create Web Site…” in the recent projects section. 1) Provide web site details Stay with the default “ASP .NET Web Site” and choose e.g. the path “C:\Inetpub\wwwroot\MyFirstPortal” as shown below. Of course you can change “MyFirstPortal” to anything you like.  You will result in the following window, and we will now start designing the very simple web site.  2) Add a table to hold your fields As we want to collect a couple of fields for a new Service Request, a HTML Table will help to display the information in a structured way to the end users. With the file “default.aspx” selected, click the “Design” button. With the mouse in the highlighted little rectangular box, from the menu select “Table” à “Insert Table”. If you want to capture 4 fields, specify 4+2 = 6 rows and two columns (we add two more rows – one for a short heading and one for the submit button). Specify e.g. 70% percent width and press “OK”.  3) Add labels Create the labels for the fields you intend to capture - in our example we’ll capture Contact Name, Subject, Area, and Description. Simply type the text in the first column of table, until it roughly looks as follows:  4) Add input fields a) Drag a “Textbox” control from the Standard section in the toolbox to the column next to the “Your name”. Assign a “(Id)” property of “txtName” in the properties window.  b) Drag a “Textbox” control from the toolbox in the column next to the “Subject” and give it a “(Id)” property of “txtSubject” in the properties window c) Drag a “DropDownList” control from the toolbox in the column next to the “Area” and give it a “(Id)” property of “selArea” in the properties window d) Drag a “Textbox” control from the toolbox in the column next to the “Description” and give it a “(Id)” property of “txtDescription” in the properties window. Enlarge it and set the “TextMode” property to “Multiline” e) Finally, add a “Button” control. Give it the id “btnSubmit”and change the “text” property to “Submit” You can change the size of the controls, so everything looks neatly.  5) Add some entries to the “Area” select box. Select it with the mouse, and press the “Source button” – you are leaving now the design mode. You will see the following HTML code: Add a couple of more lines, and provide some values. THOSE VALUES NEED TO CORRESPOND TO VALUES IN YOUR AREA FIELD IN CRM ON DEMAND!! But you don’t need to add all the values; a couple of values are enough. Complaint Product Address Change 6) Add a header image So far our web page would look really boring when we run it. A bit of branding will make a big difference, and of course it is up to you to spend as much time for that as you want. I will show you a quick way which involves minimal effort and no HTML design knowledge. a) Go to the web page of your customer – for our tutorial I choose http://www.oracle.com. A little tip: use a browser size of approx. 1024 x 768, which corresponds probably to the resolution you are going to use for your demo with a projector. b) Make a screenshot of the web page (Prnt Scrn) c) Open a Graphics Editor – in my case it is Gimp (Paintshop Pro or any other will so as well). d) Select “Edit – Paste as new” e) Now mark the top part of the web page (how much will depend on how your customer’s web page is looking), and select “Edit” à “Copy”. Below is what I copied for my example from the Oracle web page.  f) Select “Edit “ à “Paste As New”. Save the new picture as “header.jpg” in your “C:\Inetpub\wwwroot\MyFirstPortal”directory. g) Finally in MSVWD, go back to the document “default.aspx”. As you still should be in “source code” mode, scroll up until you find the “” tag. In the next line, add the following HTML code: <img src="header.jpg" alt="header"/> 7) Test our web site. New let’s test our web site: In the menu, select “Debug” à “Start Debugging” or press the green arrow in the toolbar. Your web site should open, and look e.g. as follows:  The result looks already quite good, although it doesn’t do anything useful yet. Of course perfectionists can apply the same technique for a customized footer, change the background color, change the fonts etc. In the next chapters we will populate our application with life - > means we will create a Service Request when the users presses “submit”. Step 2: Download a WSDL file To create a record in CRM On Demand, we need to use the provided WSDL file. In the CRM On Demand application, navigate to “Admin à Web Services Administration”. In the drop down list “Select Service” select the “Web Services 1.0” and press the “Go” button. There are some differences between “Web Services 1.0” and “Web Services 2.0”, and the documentation will give you more details about those. Some of the basic differences consist in data type casting, the support of attachments and a couple of new methods. But for our purposes 1.0 will work well. For this tutorial we will use the Service Request Web Service. Select “Service Request” in the “WSDL Object” box and press “Download Custom WSDL”. Using the Custom WSDLs ensures that all your custom fields are contained in the WSDL file AND that the correct SOAP address location is contained. If you use “Generic WSDL”, you won’t be able to use that without some manual tweaking – that is a common source of errors! The WSDL file will open in your web browser. Save it as “ServiceRequest.wsdl” to e.g. the root folder of your “C:\” drive. Step 3: Add WSDL to application In the solution explorer of MSVWD, select the root element, and from the context menu select “Add Web Reference”.  In the next dialog, do the following: - Enter C:\ServiceRequest.wsdl as URL (or change to the path where you saved the WSDL)
- Press the little “Go” button
- Change the “Web Reference name” to “ServiceRequest”
- Press “Add Reference”
 Step 4: Add required code to our application Now we add the code to actually create a new . In design mode, perform a double click anywhere (but not on the image) in the page “Default.aspx. This will bring you to the source code editor, and you will see the empty function “Page_Load”. 1) First paste the following lines of code at the top of the page: Imports Microsoft.VisualBasic Imports System Imports System.Net Imports System.IO 2) Now paste the code to log in inside the empty function Page_Load. Of course you need to replace the username and password with your CRM OD instance details. If Not Page.IsPostBack Then Dim SessionId, baseURL, UserName, Password As String Dim myRequest As HttpWebRequest Dim myResponse As HttpWebResponse Dim cl As WebHeaderCollection 'lbstatus.Text = "Connecting to Server" 'Change the login credential to your account baseURL = "https://secure-ausomxdsa.crmondemand.com/Services/Integration" UserName = "YOUR_CRMOD_Username” Password = "Your password" ' First, create the request to log in myRequest = HttpWebRequest.Create(New Uri(baseURL + "?command=login")) myRequest.Method = "GET" myRequest.Headers.Set("UserName", UserName) myRequest.Headers.Set("Password", Password) ' Second, send the request and capture the response myResponse = myRequest.GetResponse() ' Now, go find the set-cookie header with our session id in it cl = myResponse.Headers Dim i As Integer SessionId = "" For i = 0 To cl.Count - 1 If InStr(cl.Item(i), "JSESSIONID=") = 1 Then SessionId = cl.Item(i) If (InStr(SessionId, ";")) Then SessionId = Mid(SessionId, 1, InStr(SessionId, ";") - 1) End If End If Next Session.Add("Sessionid", SessionId) Session.Add("baseURL", baseURL) End If  3) Finally comes the code to create our Service Request. As you are still in source code mode, simply insert the following code at the second last line of code (before the closing “End Class”. Protected Sub btsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click 'Define web service Dim sr_ref As ServiceRequest.ServiceRequest sr_ref = New ServiceRequest.ServiceRequest() sr_ref.Url = Session("baseURL") + "/ServiceRequest" sr_ref.CookieContainer = New System.Net.CookieContainer sr_ref.CookieContainer.SetCookies(New Uri(Session("baseURL")), Session("Sessionid")) Dim sr_input As ServiceRequest.ServiceRequestWS_ServiceRequestInsert_Input Dim sr_output As ServiceRequest.ServiceRequestWS_ServiceRequestInsert_Output sr_input = New ServiceRequest.ServiceRequestWS_ServiceRequestInsert_Input Dim sr As ServiceRequest.ServiceRequest1 sr = New ServiceRequest.ServiceRequest1 ' Add any additional fields below!! ' sr.ContactId = "ADSA-1L6CZQ" sr.Subject = txtSubject.Text sr.Description = txtDescription.Text sr.Area = selArea.Text sr.Source = "Web" Dim Lofsr(1) As ServiceRequest.ServiceRequest1 Lofsr(0) = sr sr_input.ListOfServiceRequest = Lofsr sr_output = sr_ref.ServiceRequestInsert(sr_input) End Sub A few remarks with regards to the code: - I don’t go into the details of what each line of code is supposed to mean. Rather I give you in the appendix an example for inserting a lead. With those two examples, you should be able to figure out how to adopt it to any other entities yourself. It is always the same pattern!
- It is very easy to add additional fields. If you create a new line below “Add any additional fields below!!”, you simply need to type “sr.” This will open a dialog box, where all the existing fields are displayed to chose from.
 - The line “'sr.ContactId = "ADSA-1L6CZQ" is currently commented out by the leading single quote. I recommend assigning a valid contact row_id. You get the row_id for a given contact by drilling into the contact details in CRM OD. The URL will contain something like “ContactDetailForm.Id=ADSA-1L6CZQ “ – which is the row_id we are looking for. If you now remove the leading single quote and run the app, your new Service Request will be visible under this contact.
4) Our solution is already fully functioning. If you again start the debug mode, you can already create a new SR. But when pressing the “Submit” button, the user gets no visible feedback about success, which is not perfect. So we will make a small enhancement: a. Be sure Debug mode is stopped b. In the solution explorer select the root element, and from context menu select “Add New Item” c. In the following dialog, select Type of “Web Form” and assign a name of “Done.aspx”. Press “Add”.  d. Open the new page “Done.aspx” in Source mode. As in Step 1, add again your header image and some text, e.g. as follows  Thanks for your feedback. We will contact you shorty! e. Finally, go back to the file “Default.aspx.vb”, and add the following line as last line in the function “btsubmit_Click” Server.Transfer("Done.aspx", True)  Step 5: Define Virtual Directory Basically we would be done. Your application works, and you can now create SRs and will be routed to a confirmation page. But so far you always need to start MSVWD to run the app. Follow the next steps to make it available via a standard URL - Navigate to “Control Panel/Administrative Tools” and double-click “Internet Information Services”
- Select “YourPCName/Web Sites/Default Web Site” and select from the context menu “NewàVirtual Directory””
 - In the following dialog, give it an Alias of e.g. “MyFirstPortal” and select “Next”
- Point it to your directory C:\Inetpub\wwwroot\MyFirstPortal” and press “Next”
- Tick all permission boxes and finish the dialog
- Test it:
1. Open Internet Explorer 2. Navigate to “C:\Inetpub\wwwroot\MyFirstPortal”. Don’t panic if you get an error message” Server Application Unavailable”. On some PCs an ASP .NET won’t run due to some security “features” of ASP .NET. I added the solution in the appendix. 3. Enter some information for your SR and submit   4. Open CRM On Demand, and navigate to your test user. You will find a new Service Request related to it. Drill into this  Conclusion Hopefully you saw that it is not too hard to build your own Service Request or Lead capture web page. It took you probably 1-2 two hours to follow this tutorial. For future demos you now only need to exchange the “header jpg” to fit your customer’s web site – that shouldn’t take you more than 2 minutes! To make the tutorial not too complex, I didn’t include all possible features. Some possible areas where you can play a bit yourself with MSVWD are for example: - You could display the generated service request number to the user
- One could implement a contact lookup, so the “contact_id” is not hard-coded
- The code doesn’t log out (the session simply times out after 10 minutes
Have fun!! Appendix 1 - Sample code for capturing a lead Dim wsfb As Lead.Lead wsfb = New Lead.Lead() wsfb.Url = Session("baseURL") + "/Lead" wsfb.Proxy = proxyObj wsfb.CookieContainer = New System.Net.CookieContainer wsfb.CookieContainer.SetCookies(New Uri(Session("baseURL")), Session("Sessionid")) Dim fb As Lead.Lead1 Dim fpinput As Lead.LeadWS_LeadInsert_Input Dim fpoutput As Lead.LeadWS_LeadInsert_Output fb = New Lead.Lead1 fpinput = New Lead.LeadWS_LeadInsert_Input fb.LeadFirstName = tbFirstName.Text fb.LeadLastName = tbLastName.Text fb.LeadEmail = tbemail.Text fb.SalesRepId = "TE245-1L7NT" fb.Source = txtHow.Text fb.Campaign = "Awareness Campaign Jan09" fb.Industry = Industry.Text fb.CellularPhone = tbmp.Text fb.Description = tbdes.Text fb.ProductInterest = dlsubject Dim Lofb(1) As Lead.Lead1 Lofb(0) = fb fpinput.ListOfLead = Lofb fpoutput = wsfb.LeadInsert(fpinput) Appendix 2 – “Server Application Unavailable“ error If you get the error “Server Application Unavailable“ for every request to your new portal application, follow the steps below: 1. In Computer management, “Local Users and Groups” check that the “ASPNET” user is not disabled 2. For your c:\INETPUB directory, go to permissions and add the user ASPNET. Grant full control 3. Do the same for the folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 4. From a command prompt, issue the following: net stop iisadmin /y & net stop aspnet_state 5. From a command prompt, issue the following: net start w3svc & net start smtpsvc & net start aspnet_state
|