Developer Training Guide

Total Page:16

File Type:pdf, Size:1020Kb

Developer Training Guide

Developer Training Guide

Lab Workbook Table of Contents 1. Chapter 1: Portals Overview

There are no true exercises for this chapter, but this is a good time to check out http://community.adxstudio.com

Familiarize yourself with the documentation, check out the forums, and begin planning your projects and potential projects that involve Adxstudio Portals. 2. Chapter 2: Deployment

Use Adxstudio’s Demo builder to set up a demo portal experience. You will probably be asked to do this before the training course begins, as there is a fair amount of downtime involved.

Perform the following instructions: 3. Visit http://crm.dynamics.com and sign up for a new CRM Online trial. Be sure to log into your new org and select the US Dollar currency before continuing. You should not continue to the next step until you have successfully logged into CRM and can see the main CRM console screen. 4. Log into the Demo Builder website at https://demo.adxstudio.com and set up a profile for your contact information. This website shares a membership database with our community site and will give you the ability to participate in discussion forums and other features on our community site. Please use real contact information as we regularly prune contacts with false information and your demo could turned off as a result. 5. Enter a unique domain name for your trial (domainname.demo.adxstudio.com) 6. Enter the CRM organization URL for your CRM Online trial 7. Enter administrative username and password credentials. 8. Agree to the terms of use and click the Create Demo button. 9. Wait for an email that tells you that your environment has been configured. 10. For the duration of the trial, you can visit your unique domain name (under demo.adxstudio.com) to view the status of the demo and access your sample website

Exercise 1: Installing Adxstudio Portals

In this exercise we will get Adxstudio Portals installed on your local workstation.

Exercise 1a: Install Web Project

1. Navigate to community.adxstudio.com 2. Click the download link to download the latest Portals .msi file. 3. If you do not have an account, you will be asked to create one before you can download 4. Install the .msi file, to the default location (Program Files(x86) 5. Open IIS 6. Click Add Website… 7. Site Name: Basic Portal 8. For Physical Path, browse to C:\Program Files(x86)\ADXSTUDIO\XrmPortals\6.x.xxxx\Samples\MasterPortal 9. Set the Port number for the website or specify a specific host name, and click OK 10. Ensure that the app pool for the portal is set to .NET framework version 4.0. 11. Open VS 2012 12. Open The AdxstudioPortals solution file found under C:\Program Files (x86)\ADXSTUDIO\XrmPortals\Samples 13. Expand Master Portal 14. Open web.config 15. Modify the connection string to match your CRM online trial org’s URL, for example:

17. Open the web.config again 18. Modify the node under (near the bottom of the file) so that the websiteName=“Basic Portal” 19. Rebuild the web project. 20. Open IE and browse to the website

Exercise 1b: Install License Key

21. After you have downloaded the Adxstudio Portals solutions from Adxstudio.com, you will receive an email with a license key for a trial version. 22. Open the attachment (which is an XML file). 23. Copy the contents of the file to the clipboard. 24. Open CRM and navigate to the Settings Page. 25. Click on Adxstudio License Keys (under the Extensions group). 26. On the Ribbon, click the new button. 27. In the Name field, enter: License Key. 28. Paste the contents of the XML file that you had earlier copied to the clipboard. 29. On the Ribbon, click the Save and Close button. Exercise 2: Practice Using the WebsiteCopy tool

This exercise is meant solely to allow you to practice using the WebsiteCopy tool. We will not be using the imported portal at any point in our future exercises. Note that we are using an XML file that contains the DATA for basic portal – so we will be creating a copy of basic portal and giving it a different name.

1. Navigate to C:\Program Files (x86)\ADXSTUDIO\XrmPortals\6.x.xxxx\Utilities 2. Open WebsiteCopy.exe 3. Select “XML File” as the source of the website you will be copying 4. Click Next to select the name of the XML file you will be importing. 5. Click Browse 6. Navigate to C:\Program Files (x86)\ADXSTUDIO\XrmPortals\6.x.xxxx\Samples 7. Choose Basic Portal.xml 8. Click Next 9. Click Next 10. We now choose the destination of the websitecopy; make sure Microsoft Dynamics CRM server is selected. 11. Click Next 12. Enter your Discovery URL; to find this URL a. Open IE b. Navigate to the URL of the CRM trial you created in preparation for this training course and log in c. Navigate to Settings > Customizations > Developer resources > Service Endpoints d. Under Discovery Service you will find a URL; in Websitecopy.exe choose from the dropdown the URL that matches your discovery URL. For example https://disco.crm.dynamics.com/ 13. Enter your credentials and click Next 14. Click Connect 15. Enter Imported Portal as the website name 16. Click Next 17. Click Create Website In CRM

18. Once the utility is finished, navigate to CRM and refresh 19. Navigate to portals. 20. Open Imported Portal 21. The content for imported Portal is IDENTICAL to basic portal, because we haven’t changed anything. So let’s change something to see a difference. 22. Click Web Page 23. Open the Home page 24. Replace the entire Copy section with the content of your choice (type in anything you want). Be sure to replace the entire section. In VS 2012

25. Open the web.config again 26. Modify the node under (near the bottom of the file) so that the websiteName=“Imported Portal” 27. Rebuild the web project. 28. Open IE and browse to the website 29. Go Back and Modify the web.config again.

Now we will switch back the portal to the standard portal for the remainder of the exercises.

30. Modify the node under (near the bottom of the file) so that the websiteName=“Basic Portal” 11. Chapter 3: CMS Components

Exercise 1: Add new web pages

In this exercise, we will be creating new pages within Dynamics CRM 2011 which will subsequently be displayed within the Basic Portal. Perform the following instructions: 1. Open Internet Explorer and navigate to your CRM online trial org. 12. Click the Portals area of the SiteMap (left-hand navigation). 13. Click Websites. 14. Click Basic Portal to open the Basic Portal website record. 15. Select Web Pages. 16. On the ribbon, click the Add New Web Page button. 17. Complete the following fields: a. Name: News b. Website: Basic Portal c. Parent Page: Home d. Partial Url: news e. Display Date: today’s date f. Page Template: Page g. Publishing State: Published h. Copy: This is the news page. i. Display Order: 9 j. Leave the remainder of the fields on the form at their default values for now. 18. Click the Save and New button on the ribbon to save the record and open a new one. 19. When the new dialog is displayed, complete the following fields: k. Name: News Article One l. Website: Basic Portal m. Parent Page: News n. Partial Url: article01 o. Copy: Lorem Ipsum p. Display Order: 10 q. Display Date: today’s date r. Page Template: Page s. Publishing State: Published 20. Click the Save and New button on the ribbon to save the record and open a new one. 21. When the new dialog is displayed, complete the following fields: t. Name: News Article Two u. Website: Basic Portal v. Parent Page: News w. Partial Url: article02 x. Copy: Dolor y. Display Order: 11 z. Display Date: today’s date aa. Page Template: Page ab. Publishing State: Published 22. Click the Save and Close button on the ribbon to save the record and close the page. 23. Select Web Link Sets. 24. Open Primary Navigation. 25. Click once on the Links grid on the form. 26. Click the Add New Web Link button on the ribbon. ac. Name: News ad. Page: News ae. Publishing State: Published af. Click Save & Close In VS 2012: 27. Refresh the Adxstudio cache by resetting the Basic Portal in IIS or Rebuilding the Basic Portal Project in VS 2012 28. Navigate to the Basic Portal website in IE 29. You will notice that News now appears on the primary navigation bar at the top of the page. 30. Click on News 31. Notice the Child links that appear. These are being generated by the “Page” Page Template. 32. Chapter 4: Content Publishing

Exercise 1: Add Web Pages using Front-Side Editing

In this exercise we will add new pages using the Front-Side editing feature. Perform the following steps: 1. Navigate to Basic Portal 2. Click Sign In in the upper right-hand corner. 3. Sign in as administrator: a. Username: administrator b. Password: pass@word1 4. Navigate to the Content page by clicking the link on the primary navigation. 5. From the floating-menu, click the New button then select Child Page. 33. Complete the following properties: ag. Name: Example Content ah. Copy: This is the Example Content page 34. Leave the remainder of the properties at their default values. 35. Click the Save button to save your changes. 36. Move your mouse over the Primary Navigation and click the Edit button. 37. Click the Add button (green plus). 38. Complete the following properties: ai. Name: Example Content aj. Page: Example Content 39. Click the Save button to save the new navigation link. 40. Click the Save button to save your changes to the Primary Navigation. 41. After the page reloads, you should see your new pages on the Primary Navigation bar. 42. Navigate to Example Content page 43. Click to create a child file. Upload a sample picture from your documents folder (or download a free image from Bing images and upload that) 44. After creating the child file, try editing the “copy” attribute of the page and adding the child file, using the file picker. Experiment

1) Try Utilizing different page templates - take note of how different page templates render content, shortcuts and links in different ways. Try adding Shortcuts, Links, Files in different ways. Try experimenting with the tinyMCE editor to add rich content to the copy of your web pages: Tables, lists, etc. 45. Chapter 5: Security

Exercise 1: Configure Invitation Sign Up

In this exercise we will configure sign-up for new users to the portal. Note that by default new CRM online orgs are not configured for email routing, so we won’t make use of any of our email workflows. However, your instructor

Portal 1. Navigate to your Basic Portal website 2. If you are signed in, sign out 3. Click to Sign In 4. On the Sign In page, instead of signing in, attempt to ‘sign up’. The link to sign up is located in the grey panel above the sign in form. 5. Create an account: a. Username: jdoe b. Password: pass@word1 c. Question: Yes or No? d. Answer: Yes 6. You must now fill out your profile info. Note that you are already a portal user at this point, but before you can use the site’s features you must fill out basic contact info: a. First Name: Jon b. Last Name: Doe c. Email: [your email]

CRM: 1. Navigate to Contacts via Workplace 2. Note the contact that was created. 3. Open up the contact 4. You may be in the new “metro-style” touch interface for CRM 2011. This view is currently incompatible with multiple forms, so we will turn it off for now. If you are already in classic view, ignore this step. a. Locate three small dots at the top left-hand side of the screen b. Click on them c. Choose Switch to classic view 5. Navigate to the Portal Contact form and view the Web Authentication tab to view the fields created that associate this contact to the new portal user. 6. Navigate to Portals 7. Open Basic Portal 8. Navigate to Site Settings on the left-hand navigation pane 9. Open the Authentication/Registration/Enabled Site Setting 10. Set its value to “false”

Portal 11. Rebuild your project in VS 2012 12. Navigate to the Portal and go to the Sign In page 13. Note that now you cannot Sign up; the website is invitation-only

Experiment

1) Attempt to set the authentication mode so that you can freely sign up, but portal access is not granted until a confirmation email is responded to. Use the Authentication/Registration/RequiresConfirmation Site Setting (set the ../../RequiresInvitation Site Setting back to “false”). Note that unless you install Microsoft CRM for outlook emails won’t work. Exercise 2: Configure Web Role and Assign Web Access Permissions

In this exercises we will be creating two web roles and experimenting with how different permissions restrict what these roles can and cannot do in terms of the portal. To this end we will be adding nodes to the site map and then granting our user read/change to these nodes. In CRM: 1. Navigate to Portals, Web Sites. 2. Open Basic Portal. 3. Click on the Web Pages navigation link on the left-hand side 4. On the Ribbon, click on the Add New Web Page button. 5. Complete the following fields: a. Name: Statistics b. Website: Basic Portal c. Parent Page: Home d. Partial Url: stats e. Display Date: today’s date f. Page Template: Page g. Publishing State: Published h. Copy: This is the statistics page. i. Display Order: 9 6. On the Ribbon, Click the Save and Close button. 7. In this step we will add the new page and two child pages under news. If you already have created these pages from a previous exercise, don’t bother creating them again. Just skip to step 8 a. On the ribbon, click the Add New Web Page button. b. Complete the following fields: b.i. Name: News b.ii. Website: Basic Portal b.iii. Parent Page: Home b.iv. Partial Url: news b.v. Display Date: today’s date b.vi. Page Template: Page b.vii. Publishing State: Published b.viii. Copy: This is the news page. b.ix. Display Order: 10 c. Click the Save and New button on the ribbon to save the record and open a new one. d. When the new dialog is displayed, complete the following fields: d.i. Name: News Article One d.ii. Website: Basic Portal d.iii. Parent Page: News d.iv. Partial Url: article01 d.v. Page Template: Page d.vi. Publishing State: Published d.vii. Copy: Lorem Ipsum d.viii. Display Order: 1 e. Click the Save and New button on the ribbon to save the record and open a new one. f. When the new dialog is displayed, complete the following fields: f.i. Name: News Article Two f.ii. Website: Basic Portal f.iii. Parent Page: News f.iv. Partial Url: article02 f.v. Page Template: Page f.vi. Publishing State: Published f.vii. Copy: Dolor f.viii. Display Order: 2 g. Click the Save and Close button on the ribbon to save the record and close the page. 8. Click the Web Roles navigation link. 9. On the Ribbon, click the Add New Web Role button. 10. Complete the following fields: a. Name: News Editor b. Website: Basic Portal c. Authenticated Users Role: No 11. On the Ribbon, click the Save button. 12. Click on the Web Page Access Control navigation link. 13. On the Ribbon, click the Add Existing Web Page Access Control button. 14. When the “Look Up Records” dialog appears, click the New button. 15. Complete the following fields: a. Name: View Statistics b. Website: Basic Portal c. Web Page: Statistics d. Right: Restrict Read e. Leave the remainder of the fields on the form at their default values for now 16. On the Ribbon, Click the Save and Close button. 17. Click OK on the Look up Records dialog 18. On the Ribbon, click the Add Existing Web Page Access Control button. 19. When the “Look Up Records” dialog appears, click the New button. 20. Complete the following fields: a. Name: Grant News Change to News Editors b. Website: Basic Portal c. Web Page: News d. Right: Grant Change e. Leave the remainder of the fields on the form at their default values for now 21. On the Ribbon, Click the Save and Close button 22. Click OK 23. Navigate to Contacts 24. Click to Add an existing contact to this web role 25. In the lookup Dialog, click New 26. You may be in the new “metro-style” touch interface for CRM 2011. This view is currently incompatible with multiple forms, so we will turn it off for now. If you are already in classic view, ignore this step. a. Locate three small dots at the top left-hand side of the screen b. Click on them c. Choose Switch to classic view 27. Navigate to the Portal Contact form and view the Web Authentication tab to view the fields created that associate this contact to the new portal user. 28. Give the Contact the following fields: a. First name: Jon b. Last Name: doe c. Username: jdoe d. Reset Password To: pass@word1 e. Logon Enabled: true 29. Click Save & Close VS 2012: 30. Rebuild the MasterPortal project 31. Navigate to the Basic Portal in IE 32. Navigate to the URL for the statistics page: http://mywebsite/stats 33. Notice you do not have read access to the page 34. Login as Jon Doe: jdoe; pass@word1 35. Navigate again to the statistics page 36. Notice you have access 37. Navigate to the News page 38. Notice you may edit the content on this page 39. Navigate to News Article 1 40. Notice you also have access to this page 46. Chapter 6: Community Features

Exercise 1: Add a Forum

Configure the Community Portal 1. Open VS 2012 2. Open The AdxstudioPortals solution file found under C:\Program Files (x86)\ADXSTUDIO\XrmPortals\6.x.xxxx\Samples 3. Expand Master Portal 4. Open web.config 5. Modify the connection string to match your CRM online trial org’s URL, for example:

6. Open IE and browse to the website 7. Open the web.config again 8. Modify the node under (near the bottom of the file) so that the websiteName=“Community Portal” 9. Rebuild the web project. 10. Open IE and browse to the website

Add a Forum 11. Navigate to the CRM 12. Click the Portals area of the SiteMap (left-hand navigation). 13. Click Websites. 14. Click Community Portal to open the Community Portal website record. 15. Click Forums on the left-hand nav bar 16. Click to Add a New Forum 17. Give it the following attributes: a. Name: Example Forum b. Website: Community Portal c. Parent Page: Forums d. Partial URL: example-forum e. Publishing State: Published f. Forum Page Template: Forum g. Thread Page Template: Forum Thread 18. Save & Close In VS 2012 19. Rebuild the Project 20. Navigate to the Community Portal 21. Navigate to Forums 22. Notice that the new example forum you have created is visible 23. Click to view the forum. Note that because there are no forum threads, the only option at this point is to create a new thread. Exercise 2: Add a Forum Thread

1. Navigate to the Community Portal 2. Log in as administrator a. Username: administrator b. Password: pass@word1 3. Navigate to a Forum (For example, the Example Forum you created in the last exercise) 4. Navigate to the “Create a New Thread” section of the page 5. Fill in the required fields to add a new forum thread a. Thread Title: Question about Forums b. Type: Question c. Content: “I have a question about forums, can someone help me?” 6. Click the Create this Thread button 7. You will be taken to the new thread you have created 8. Post a reply: Type “Yes” in the Content box and click Post this Reply 9. Navigate to the Support Forum page by clicking the link in the breadcrumbs 10. Notice the thread you created: Notice it is a question (indicated by the question mark icon) and that it has one reply 11. Navigate back into the thread 12. Click the Mark as answer button next to the response you just posted 13. If you navigate back to the Support Forum page, you will notice the thread is now marked as answered 14. Navigate back into the thread. 15. Click Edit on the toolbar at the upper right-hand corner of your browser 16. Check “Sticky?” 17. Click Save 18. Navigate to the Support Forum page by clicking the link in the breadcrumbs 19. Notice the thread is Sticky now. Exercise 3: Add an Idea Forum

CRM 1. Navigate to the CRM 2. Click the Portals area of the SiteMap (left-hand navigation). 3. Click Websites. 4. Click Community Portal to open the Community Portal website record. 5. Click Idea Forums on the left-hand navigation area 6. Click to Add a New Idea Forum 7. Give the Idea Forum the Following values: a. Title: Example Idea Forum b. Website: Community Portal c. Partial URL: example-idea-forum d. Type of Voting: Rating e. Maximum Rating: 5 8. Click Save & Close In VS 2012 9. Rebuild the Project 10. Navigate to the Community Portal 11. Click on Ideas on the primary navigation bar 12. Notice that the new Example Idea Forum you have created is visible Exercise 4: Add an Idea

1. Navigate to the Community Portal website 2. Sign in as Administrator if you are not already signed in. 3. Click on Ideas on the primary navigation bar 4. Open the Example Idea Forum we create in the previous exercise 5. Navigate to the Suggest a New Idea part of the page 6. In the Idea textbox, type “Example Idea” 7. For the Description, type “Lorem Ipsum” 8. Click Submit Idea 9. Note that your Idea appears 10. You may up-vote your Idea by clicking on the Up-pointing arrow button to the left of the idea. 11. You may assign a score to the idea. Try clicking +3 12. The Idea will now have a rating of 4.

Experiment: Sign out of the portal. You are now anonymous. Navigate back to that same idea as before? Can you vote on it? Comment on it? Why? Try playing around with different Idea settings to get different effects in terms for how Ideas can be voted on. Exercise 5: Add a Blog

14. Navigate to the CRM 15. Click the Portals area of the SiteMap (left-hand navigation). 16. Click Websites. 17. Click Community Portal to open the Community Portal website record. 18. Click Blogs on the left-hand navigation area 19. Click to Add a New Blog 20. Give the Blog the Following values: a. Name: My Own Little Blog b. Website: Community Portal c. Parent Page: Blogs d. Partial Url: little-blog e. Home Template: Blog f. Post Template: Blog Post g. Archive Template: Blog Search h. Summary: “This is my Own Little Blog” i. Comment Policy: Open 21. Click Save 22. Click on Author Roles on the left-hand side of the Blog form window 23. Click to Add Existing Role 24. Add the Administrators role related to the Community Portal Website. 25. Click OK 26. Save & Close the Blog In VS 2012 27. Rebuild the Project 28. Navigate to the Community Portal 29. Click on Blogs on the primary navigation bar 30. Notice that the new Blog you have created is visible – a Link to it shows up on the right-hand sidebar. Exercise 6: Add a Blog Post

1. Navigate to the Community Portal website 2. Sign in as Administrator if you are not already signed in. 3. Click on Blogs on the primary navigation bar 4. Open the Blog we create in the previous exercise (My Own Little Blog) by clicking on the link on the right-hand sidebar 5. Click New > Blog Post on the toolbox in the upper-right hand corner of the browser 6. Name the Blog Post “This is my First Post” and enter in something funny or interesting in the Copy section. 7. Give the Blog Post a partial URL of first-post and Click Save 8. You Blog Post is now up on the portal.

Experiment: Try commenting on the Blog post both as yourself and as anonymous users. How do you enable Ratings for the Blog post? How to blog posts get aggregated? Play with the options and let the instructor know if you have any questions. 47. Chapter 7: Portal Theming

Exercise 1: Edit the Copy of a Page Using Bootstrap Elements

1. Navigate to the Basic Portal Website 2. Login as Administrator if you are not already logged in. 3. Navigate to Content > Content Page 4. Edit the Copy using front-side editing 5. The tinyMCE editor will appear Let’s play with a new simple styles that we can attach to elements: 6. Beneath the current content block, type a sentence “This is a sentence” 7. Follow this with a few paragraph breaks by hitting enter on your keyboard several times 8. Highlight the sentence and from the Styles dropdown select “Alert Info” 9. Save 10. Notice that the sentence you added is surrounded by an alert box 11. Click to edit the content block again. 12. Place your text cursor beneath the alert block you added 13. Insert a table by clicking the insert table button, which is on the bottom row of buttons, all the way to the left-hand side (two down from the save button) 14. Choose 3 rows and 3 columns 15. Place some dummy content spread throughout the table 16. Save 17. Notice how the table looks 18. Click to edit the content block again. 19. Select the table 20. Click to Insert and Attribute by clicking the button just left of the Format Dropdown 21. Click the Class dropdown and select table (begin typing the word to have the dropdown find it for you) 22. Save 23. Notice how the table looks 24. Click to edit the content block again. 25. Now Edit the Markup by clicking the html button 26. Find the

node. It should have an attribute class=“table”. Change this to class=“table table-striped” 27. Save 28. Notice how the table looks Now let’s do some very basic scaffolding. If you are not comfortable with HTML, you can choose to skip this exercise. Alternatively, you can take a stab at it and ask the instructor for help. 29. Click to edit the content block again. 30. Split the original Lorem Ipsum content block into two paragraphs 31. Now Edit the Markup by clicking the html button 32. Notice the original main content block is split into two

tags: one for each of the two paragraphs you just split it into. 33. Wrap both of these

tags within a

tag that has class=“row” 34. Now wrap the first

tag within a

tag that has class=“span3” 35. Now wrap the second

tag within a

tag that has class=“span5” 36. Notice you have two paragraphs present in a side-by-side paragraph format.

Experiment: Choose several components from the Bootstrap website under the “components” or “Javascript” tab. Try to do as much as you can with the content editor, but feel free to crack open VS 2012 and edit the page templates if you wish to do. Try to do something really cool. Exercise 2: Roll a Custom Bootstrap Theme for your Portal

1. Navigate to http://bootswatchr.com/ OR http://www.bootstrapthemeroller.com/ 2. Click to start Creating/ Rolling your theme 3. BE CREATIVE 4. Once you are finished creating your theme, Download the CSS file the matches your theme. If using themeroller, just click the download link to grab a zip file which contains your bootstrap.min.css file. If using bootswatchr, you’ll need to click the CSS dropdown near the top of the page and choose minified and then copy and paste everything into a file called bootstrap.min.css 5. Navigate to the Basic Portal Website 6. Sign in as administrator 7. On the home page, click to create a New child file by clicking New > child file on the front-side editing toolbar. 8. Choose the bootstrap.min.css file you create by rolling your theme as the file upload. 9. For the name and partial URL both, enter bootstrap.min.css 10. Click Save 11. Refresh your cache by resetting the site in IIS, or rebuilding the project in VS 2012. 12. Your theme should be applied to the portal! 48. Chapter 8: Displaying Forms

Exercise 1: Edit a CRM Form for lead

In this exercise, we will set up a CRM form which we will later use to demonstrate the functionality for the CrmEntityFormView control, the Entity Form feature, and the Web Form feature.

Please perform the following: In CRM, first we will create the CRM form itself: 1. Open Internet Explorer and navigate to your CRM online trial org 49. Navigate to the Settings Area of the Site Map 50. Click Customizations 51. Click Customize the System 52. Select Lead from the list of entities on the left navigation of the solution editor window. 53. Click Forms 54. Open the form titled Web Form 55. Click to Save As… 56. Name the form New Contact Us Form 57. Remove the following fields from the form: Street 1, City, State/Province, ZIP/Postal Code, Country/Region, Description 58. Save and Close the form again. 59. Reorder the forms so that the new form you create is not the default form: ak. Click Form Order al. Click Main Form Set am. Move the newly created form to the bottom of the list an. Click OK 60. Click Publish All Customizations – if this option isn’t shown, click to “information on the left- hand side of the main solution window Exercise 2: Create a Managed Form on the Portal

In this exercise, we will utilize the CrmEntityFormView control to render our Contact Us form on the portal.

1. Navigate to Portals – we will now add the page to the website that will render this form 61. Open the Basic Portal website. 62. Create a new Page Template for your form: ao. Click Page Templates ap. Click New aq. Specify the Name as Managed Forms Contact Us ar. Website: Basic Portal as. Specify the Rewrite URL as ~/Pages/CrmEntityFormViewContactUs.aspx (we will create this in the web project later) at. Click Save & Close 63. Create a new Web Page using this template: au. Click Web Pages av. Click New aw. Specify the Name as Managed Forms Contact Us ax. Select the appropriate Website ay. Select the Home page as the Parent Page az. Specify managed-forms-contact-us as the partial URL ba. Select the Managed Forms Contact Us Page Template created earlier bb. Select Published as the publishing state bc. Click Save & Close 64. Navigate to Web Link Sets 65. Click Primary Navigation 66. Click Web Links 67. Click New 68. Give the web link the follow values: bd. Name: Managed Contact Us be. Page: Managed Forms Contact Us bf. Publishing State: Published 69. Save & Close

In Visual Studio 70. Open Visual Studio 2012. 71. Select File, Open Project. 72. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. 73. Select AdxstudioPortals.sln then click the Open button. 74. In the Solution Explorer, expand the project: MasterPortal. 75. Create a new ASP.NET Web Form using Master Page in the ~/pages folder 76. Use the WebForms.master page 77. Save the file as “CrmEntityFormViewContactUs.aspx” in Pages folder contained in the root of the project. 78. Replace the markup of the page with the following:

79. Also add the following using Statements, to the using declarations at the top of the code-behind:

using Adxstudio.Xrm.Web.UI.WebControls;

using Microsoft.Xrm.Portal.Web.UI.WebControls; 80. Now add the following method to the code behind. This event handler is triggered when the form has successfully inserted the new record upon form submission: protected void OnItemInserted(object sender, CrmEntityFormViewInsertedEventArgs e) { ContactForm.Visible = false; ConfirmationMessage.Visible = true; } 81. Build the project.

Let’s try out the form in the portal: 82. Navigate to the Basic Portal. 83. Navigate to the Managed Form Contact Us page on the portal. You should now see a form resembling the one you created in CRM. 84. Fill in the form bg. First name: John bh. Last Name: Doe bi. Remaining values can be whatever you wish

CRM: 1. View the Submitted Leads in the CRM bj. Navigate to Sales bk. Click Leads bl. Find the John Doe record and open it bm.Note the lead created matches the data previously entered though the portal. Exercise 3: Create an Entity Form on the Portal

1. Navigate to Portals – we will now add the page to the website that will render this form 2. Navigate to Entity Forms 3. Create a new Entity Form a. Name: Entity Form Contact Us b. Entity Name: Lead c. Form Name: New Contact Us Form d. Mode: Insert e. Click Save & Close 85. Open the Basic Portal website. 86. Create a new Web Page: bn. Click Web Pages bo. Click New bp. Specify the Name as Entity Form Contact Us bq. Select the appropriate Website br. Select the Home page as the Parent Page bs. Specify entity-form-contact-us as the partial URL bt. Select the Full Page Page Template bu. Select Published as the publishing state bv. Select Entity Form Contact Us as the Entity Form bw. Click Save & Close 87. Navigate to Web Link Sets 88. Click Primary Navigation 89. Click Web Links 90. Click New 91. Give the web link the follow values: bx. Name: Entity Form Contact Us by. Page: Entity Form Contact Us bz. Publishing State: Published 92. Save & Close

Let’s try out the form in the portal: 93. Rebuild your VS 2012 project 94. Navigate to the Basic Portal. 95. Navigate to the Entity Form Contact Us page on the portal. You should now see a form resembling the one you created in CRM. Exercise 4: Set Up a Web Form

Here we will be creating essentially the same result as in the previous exercises, but using web forms. We will be using the same New Contact Us Web Form we created earlier.

In CRM: 1. Create a New Web Page, Web Form, and Web Form Step for your lead (Contact Us) Form: a. Navigate to Portals > Basic Portal > Web Pages b. Click New c. Give the web page the following values: c.i. Name: Contact Us Web Form c.ii. Partial Url : contact-us-web-form c.iii. Publishing State: published c.iv. Page Template: Full Page c.v. Website: Basic Portal c.vi. Parent Page: Home d. Click Save 2. Click to Open the Web Form lookup window; so that you can associate the Contact us form to the page 3. Click New 4. Specify a Name for the Web Form: “Contact Us” 5. Click Save 6. Click Start Step lookup button 7. Click New, and give the step the follow values: a. Name: Load Contact Us Form b. Web Form: Contact Us c. Type: Load Form d. Entity Logical Name: lead e. Mode: Insert f. Form Name: New Contact Us Form g. Success Message: Thank you for contacting us. 8. Click Save & Close or click OK on all open windows 96. Navigate to Web Link Sets 97. Click Primary Navigation 98. Click Web Links 99. Click New 100. Give the web link the follow values: ca. Name: Contact Us Web Form cb. Page: Contact Us Web Form cc. Publishing State: Published 101. Save & Close

Let’s try out the form in the portal: 102. Rebuild your VS 2012 project 103. Navigate to the Basic Portal. 104. Navigate to the Web Form Contact Us page on the portal. You should now see a form resembling the one you created in CRM. Exercise 5: Set up a Survey

In CRM, We will be creating a new entity that represents a survey we will be presenting to users via the portal. This is represented by an entity in the CRM containing the questions for the survey. This means that the entity itself represents the specific survey, while the records created by the web form submission represent survey submissions.

Exercise 5a: Create the Survey Entity in CRM

1. Login to CRM 2. Navigate to Settings 3. Click Customizations 4. Click Customize the System 5. Click New > Entity 6. Fill in the required fields: a. Choose a name the reflects this is a survey: Customer Support Survey b. Plural Name: Customer Support Survey c. Logical Name: new_customersupportsurvey d. Set the entity to display in the Workplace area of the site map 7. Click Save Now we add our questions to the survey 8. Click Fields 9. Add Fields representing questions: a. Add a Text Area Question a.i. Click New a.ii. Set the Name to “Description” a.iii. Logical name: new_description a.iv. Requirement Level: Required a.v. Choose Multiple Lines of Text for the Type a.vi. Save & Close b. Add a Text Area Question b.i. Click New b.ii. The Name for the question: “How Heard” b.iii. Logical name: new_howheard b.iv. Choose Single Line of Text for the Type b.v. Save & Close c. Add a True/False Question c.i. Click New c.ii. The Name for the question: “Gold Star” c.iii. Logical name: new_goldstar c.iv. Choose Two Options as the Type c.v. Save & Close d. Add a Multiple Choice Question d.i. Add a series of fields, each one representing an answer to the question you have planned (“How may we contact you?”) d.ii. Click New d.iii. Name: “Email” d.iv. Logical name: new_mc1_email d.v. Choose Two Options as the Type d.vi. Save & Close d.vii. Click New d.viii. Name: “Phone” d.ix. Logical name: new_mc1_phone d.x. Choose Two Options as the Type d.xi. Save & Close d.xii. Click New d.xiii. Name: “Fax” d.xiv. Logical name: new_mc1_fax d.xv. Choose Two Options as the Type d.xvi. Save & Close e. Add a Likert Scale Question e.i. Click New e.ii. The Name for the question: “Quality Rating” e.iii. Logical Name: new_qualityrating e.iv. Select the Option Set Type e.v. Choose Use an Existing Option Set e.vi. Choose Likert Scale Quality e.vii. Save & Close 10. We will also add a field that will record the current portal user. a. Click New b. Display Name: Contact c. (Logical) Name: new_contactid d. Type: Lookup e. Target Record Type: Contact f. Relationship Name: new_contact_customersupportsurvey g. Save & Close 11. From the Customer Support entity you have just created (either the window that is still open or, if you closed it – by navigating to the entity in the solution window) Click Forms; it is now time to create the CRM forms that will be rendered to display the survey 12. Click to create a new “main form”. 13. Click Save As and save it as Survey Step 2 14. Click Save As and save it as Survey Step 1 First we will edit the form for step 1 of the survey 15. Click on the Name field on the form, and then click Properties 16. Uncheck “Visible by default” 17. Check “Field is Read-only” 18. Close Properties window 19. Click on the Owner field on the form, then click Properties 20. Uncheck “Visible by default” 21. Check “Field is Read-only” 22. Close properties window 23. Click on the Notes tab on the form 24. Click Remove 25. Add the text area and true/false question to the form, in a layout that you desire: a. Drag and Drop the Description field onto the form b. Click on it and click Properties c. Set the label to “Please give a description of the problem you contacted us for” d. Click OK e. Drag and Drop the How Heard field onto the form f. Click on it and click Properties g. Set the label to “How did you first hear about us?” h. Drag and drop the Gold Star field onto the form i. Click on it and click Properties j. Set the label to “Are you a gold star member?” 26. Save & Close the form Now we will edit the form for Step 2 27. Click to open the Survey Step 2 form 28. Click on the Name field on the form and click Properties 29. Uncheck “Visible by default” 30. Check “Field is Read-only” 31. Click on the Owner field on the form, the click Properties 32. Uncheck “Visible by default” 33. Check “Field is Read-only” 34. Click on the Notes tab on the form 35. Click Remove 36. Drag and drop the Quality Rating field onto the form 37. Click on it and click properties 38. Set the label to “Please Rate the quality of service you received from us” 39. Add the multiple choice question: a. Click the Insert tab above the ribbon b. Click for a Two-Column section c. Double-click on the newly created section d. Set the Label of this section to be: “How may we contact you?” e. Click Show the label of this section on the Form f. Click OK g. Add each response to this question you created earlier to this section: g.i. Drag and drop the ‘Email’ field onto the form g.ii. Double-click on it or select it and click properties g.iii. Click Formatting g.iv. Select Check Box as the Control Formatting g.v. Click OK g.vi. Drag and drop the ‘Fax’ field onto the form g.vii. Double-click on it or select it and click properties g.viii. Click Formatting g.ix. Select Check Box as the Control Formatting g.x. Click OK g.xi. Drag and drop the Phone field onto the form g.xii. Double-click on it or select it and click properties g.xiii. Click Formatting g.xiv. Select Check Box as the Control Formatting g.xv. Click OK g.xvi. Save & Close 40. Click on the Form Order and choose Main Form Set 41. Move the Information form to the top 42. Click OK Now we edit the main information form so we can view the results later. 43. Open the Information Form 44. Add the text area and true/false question to the form, in a layout that you desire: a. Drag and Drop the Description field onto the form b. Click on it and click Properties c. Set the label to “Please give a description of the problem you contacted us for” d. Click OK e. Drag and Drop the How Heard field onto the form f. Click on it and click Properties g. Set the label to “How did you first hear about us?” h. Drag and drop the Gold Star field onto the form i. Click on it and click Properties j. Set the label to “Are you a gold star member?” 45. Drag and drop the Quality Rating field onto the form 46. Click on it and click properties 47. Set the label to “Please Rate the quality of service you received from us” 48. Add the multiple choice question: a. Click the Insert tab above the ribbon b. Click for a Two-Column section c. Double-click on the newly created section d. Set the Label of this section to be: “How may we contact you?” e. Click Show the label of this section on the Form f. Click OK g. Add each response to this question you created earlier to this section: g.i. Drag and drop the ‘Email’ field onto the form g.ii. Double-click on it or select it and click properties g.iii. Click Formatting g.iv. Select Check Box as the Control Formatting g.v. Click OK g.vi. Drag and drop the ‘Fax’ field onto the form g.vii. Double-click on it or select it and click properties g.viii. Click Formatting g.ix. Select Check Box as the Control Formatting g.x. Click OK g.xi. Drag and drop the Phone field onto the form g.xii. Double-click on it or select it and click properties g.xiii. Click Formatting g.xiv. Select Check Box as the Control Formatting g.xv. Click OK 49. Finally, add the Contact Lookup field to the form, so we know who wrote the survey 50. Save & Close 51. Click Publish All Customizations Exercise 5b: Create the Web Form Data

Now that the Entity and the CRM forms have been created, we can create the web form data for our survey and associate the survey with a web page so that it shows up on our portal. Let the instructor know if at any point you get lost during this process. 52. Navigate to Portals -> Web Pages 53. Click New 54. Give the web page the following values: a. Name: Customer Support Survey b. Partial Url : customer-survey c. Publishing State: Published d. Website: Basic Portal e. Parent Page: Home f. Page Template: Full Page g. Click Save 55. Click to Open the Web Form lookup window – we will add the web form to the page (if you closed the web page form, you can create the web form first then later add it to this web page by re-opening it) 56. Click New to create a new web form. 57. Specify a Name for the Web Form: “Customer Support Survey” 58. Set Multiple Records Per User Permitted to “false” 59. Set Authentication Required to “true” 60. Click Save (but do not close the form – we aren’t done yet!) 61. Click Start Step lookup button 62. Click New, and give the step the follow values: a. Name: Survey Step 1 b. Type: Load Form c. Entity Logical Name: new_customersupportsurvey d. Mode: Insert e. Form Name: Survey Step 1 f. Associate Current Portal User: True (check it) g. Target Entity Portal User Lookup Attribute: Contact (new_contactid) 63. Click Save 64. Click Next Step lookup button 65. Click New, and give the step the follow values: a. Name: Survey Step 2 b. Type: Load Form c. Web Form: Customer Support Survey d. Entity Logical Name: new_customersupportsurvey e. Mode: Edit f. Source Type: Result From Previous Step g. Form Name: Survey Step 2 h. Success Message: “Thank you for your submission” i. Save (don’t close it – we are going to add a related entity) 66. Click Metadata from the Survey Step 2 left navigation 67. Click Add New Web Form Metadata 68. Specify the Attribute Logical Name to be the logical name of the Likert scale question you created: new_qualityrating 69. Select Option Set as Horizontal Radio Button List from the style dropdown, Control Style section 70. Click Save & Close or OK all windows that remain open

Portal 71. Rebuild your web project or reset the website in IIS to reset the cache 72. Navigate to the portal 73. Sign in as administrator 74. Edit the primary navigation Web Link Set by clicking the Edit button that appears when you mouse of the primary navigation. 75. Add a new web link by clicking the “+” icon 76. Fill in the following fields: a. Name: Survey b. Page: Customer Support Survey c. Save 77. You may now take the survey, navigate to the URL you specified for your survey and take the survey.

Exercise 5c: View Survey Results

In CRM

1. Navigate to Workplace 2. Navigate to Customer Support Surveys 3. Locate the survey submission you just created and open it 4. From here you can view the results of the survey by reading the form. Experiment

1) Attempt adding more and different question types, Web Forms Steps, and metadata to your survey.

2) What sorts of processes would you build to surround this survey? What sorts of workflows would be appropriate? How would the survey be distributed? How would the data be used? Jot down some ideas.

3) Try Creating a Report in CRM to view the results of the survey. What’s the best way to create a meaningful report? Any limitations? 105. Chapter 9: Displaying Views

Exercise 1: Surface a CRM View as Entity List

In this exercise, we will set up a CRM view which we will then surface on the portal

Please perform the following: In CRM, first we will create the CRM form itself: 1. Open Internet Explorer and navigate to your CRM online trial org 106. Navigate to the Settings Area of the Site Map 107. Click Customizations 108. Click Customize the System 109. Select Lead from the list of entities on the left navigation of the solution editor window. 110. Click Views 111. Open the view titled Open Leads 112. Click to Save As… 113. Name the form New Open Leads View 114. Click the Name Column and click Change Properties 115. Change the width to 200px and click save 116. Remove the Created On column from the form 117. Click Add Columns 118. Check Email and click OK 119. Set the width of the Email Column to 200px 120. Save and Close the view again. 121. Click Publish All Customizations – if this option isn’t shown, click to “information on the left-hand side of the main solution window 122. Navigate to Portals 123. Open up the Basic Portal Website record 124. Create a new Web Page: cd. Click Web Pages ce. Click New cf. Specify the Name as Open Leads List cg. Select the appropriate Website ch. Select the Home page as the Parent Page ci. Specify open-leads-list as the partial URL cj. Select the Full Page Page Template ck. Select Published as the publishing state cl. Click Save 125. Open the Entity List lookup window 126. Click New 127. Now we are creating a new Entity View record to surface on the page 128. Fill in the following attributes: cm. Name: Open Leads List cn. Entity Name: Lead (lead) co. View: New Open Leads View cp. Page Size: 10 129. Click Save & Close 130. Click OK 131. Click Save & Close 132. Navigate to Web Link Sets 133. Click Primary Navigation 134. Click Web Links 135. Click New 136. Give the web link the follow values: cq. Name: Open Leads List cr. Page: Open Leads List cs. Publishing State: Published 137. Save & Close

Let’s try out the form in the portal: 1. Rebuild your VS 2012 project 138. Navigate to the Basic Portal. 139. Navigate to the Open Leads List page on the portal and view the list you created. Exercise 2: Add an Edit Form to the Leads List

We will now make Records displayed on our Leads list editable by adding an edit page to our Entity List. To do this, we will create a Page that has an entity form associated with it and assign this as the details page for the Entity List. We will re-use our contact us form we created earlier.

1. In the CRM, navigate to Portals 2. Click Entity Lists 3. Open up the Open Leads List Entity List you created in the previous exercise 4. Click the Web Page for Details View lookup Window 5. Click New 6. Create the Web Page that will be used for the details page. Give it the following attributes: a. Name: Lead Edit Form b. Website: Basic Portal c. Parent Page: Open Leads List d. Partial Url: edit e. Page Template: Full Page f. Publishing State: Published 7. Click Save 8. Now Open the Entity Form Lookup Window. 9. Click New 10. We will now create a new Entity Form to use in edit mode. We will reuse the Contact Us form we created in the previous chapter. a. Name: Edit Lead Form b. Entity Name: Lead c. Form Name: New Contact Us Form d. Mode: Edit e. Record Source Type: Query String f. Record ID Query String Parameter Name: id 11. Save & Close or click OK on all open windows Let’s try out the form in the portal: 2. Rebuild your VS 2012 project 140. Navigate to the Basic Portal. 141. Navigate to the Open Leads List page on the portal and view the list you created. Note you have now an edit form.

Experiment: Try adding a redirect to your edit form so after completing the form you will be taken back to the Entity List page. Once you have done this, try replacing your edit form with a web form instead that does the same thing. Split the web form into multiple steps afterwards. Play around with the options.

142. Chapter 10: Event Management

Exercise 1: Add Events to Basic Portal

First, we will enable Events for Basic Portal by added the Page Template to render out Event Schedules from the Events Area in Master Portal

1. In CRM, Navigate to Portals > Basic Portal

2. Navigate to Page Templates

3. Click Add New Page Template

4. Enter Events as the name

5. Add “~/Areas/Events/Pages/Events.aspx” as the Rewrite URL

6. Click Save & Close

7. Navigate to Web Pages

8. Click Add New Web Page

9. Fill out the following fields:

a. Name: Events

b. Website: Basic Portal

c. Parent Page: Home

d. Partial URL: events

e. Page Template: Events f. Publishing State: Publishing

g. Save & Close

Second, we will be creating a new event and event schedule that will be added to the portal

1. Navigate to Events

2. Click Add New Event

3. Adxstudio Portals

4. Fill in the required fields

a. Name: Adxstudio Portals Training

b. Website: Basic Portal

c. Parent Page: Events

d. Partial Url: adxstudio-portals-training

e. Publishing State: Published

5. Click Event Schedules on the Left-hand side Navigation

6. 143. Chapter 11: Customer Support

Exercise 1: Manage Cases

1. Navigate to the Community Portal through Demo Builder. If you forget the URL for community Portal, you will be able to find t by navigating into the CRM and going to your website bindings. 2. Click Sign In in the upper right hand corner a. Username: administrator b. Password: pass@word1 3. Navigate to Help Desk 4. Click on the search bar and type in “Lorem Ipsum”. 5. Notice the result links that come up: You can’t create a case until you have at least searched for existing results first. Click on one of them and inspect. 6. Click the Back button in your browser 7. Click the Open a New Support Request button at the bottom of the search results 8. When it asks you to choose a customer to assign the Support Request to, choose Adxstudio Inc. 9. Click Next 10. In the “Details of the Problem” field, enter “Lorem Ipsum Dolor” 11. Enter in the case information: a. Title: “Lorem Ipsum” b. Case Type: Problem c. Customer: Assigned to Me d. Additional Notes: “Dolor Pellentesque nunc sapien.” 12. Click Create Case 13. Click Add Note in the upper right hand corner 14. Fill in the note details: This is an example note 15. Upload an attachment by click on the “choose file” button. Choose an image from the sample images folder in windows. 16. Notice that the note is added at the button the case screen. 17. Click Resolve Case in the upper right corner. 18. Specify a resolution of “Lorem Ipsum” 19. Specify a description of “Case was resolved via Lorem Ipsum” 20. Click Resolve Case 21. The case is now resolved. Click Reopen Case and confirm. 22. Click Cancel Case and confirm. The case is now cancelled. 23. Click Reopen Case. 24. In the breadcrumbs at the top of the page, click Support. 25. Note that the case you created is in the list of cases under the search bar. 26. Try creating another case, except this time for the customer, try assigning the case to your parent customer account. 27. Go back to the support page, and click the view dropdown to adjust viewing your cases vs. your parent company cases.

144. Chapter 12: Service Requests

Exercise 1: Create a new Service Request on the Portal

1. Navigate to the Government Portal through the demo builder 2. Log in as administrator if you are not already logged in 3. Navigate to 311 4. Click to open a Pothole service request 5. Fill in the form – if possible, try using a real address for the “Location” field that will appear on a map (like your house or place of work, or a famous landmark in your home city) 6. Click submit. Take Note of the Service Request Number 7. Navigate again to 311 8. Click View Map 9. Notice that your service request is located on the map 10. In the upper right hand corner, you will see your logged-in username (System Administrator) 11. Click on the down-pointing arrow next to your logged-in username to view the profile navigation web link set 12. Click My Service Requests 13. You will see your service request that you created earlier

Exercise 2: Create a new Service Request Entity

In this exercise we will add a new service request type. This can be done without needing to make any code changes to the web project. First we will be creating a new custom service request entity, to store the data for our custom service request type 1. In CRM, navigate to Settings 2. Navigate to Customize the System 3. Click Entities 4. Click New to create a new entity 5. Set the required fields: a. Display Name: Special Request b. Plural Name: Special Requests c. Name: new_specialrequest d. Ownership: User or Team e. Check “Service” in sitemap areas section

f. Ensure Notes is checked

g. Ensure Activities are checked

h. Check Queues

6. Click Save

7. Click Fields

8. Add Fields for all the mandatory Fields that need to be mapped to the generic service request entity. a. Add the “Closed Date” field a.i. Click New a.ii. Set the Display Name to “Closed Date” a.iii. Logical name: new_closeddate a.iv. Type: Date and Time a.v. Format: Date and Time a.vi. Save & Close b. Add the “Email Address” field b.i. Click New b.ii. Set the Display Name to “Email Address” b.iii. Logical name: new_emailaddress b.iv. Type: Single Line of Text b.v. Format: Email b.vi. Save & Close c. Add the “First Name” field c.i. Click New c.ii. Set the Display Name to “First Name” c.iii. Logical name: new_firstname c.iv. Type: Single Line of Text c.v. Format: Text c.vi. Save & Close d. Add the “Last Name” field d.i. Click New d.ii. Set the Display Name to “Last Name” d.iii. Logical name: new_lastname d.iv. Type: Single Line of Text d.v. Format: Text d.vi. Save & Close e. Add the “Latitude” field e.i. Click New e.ii. Set the Display Name to “Latitude” e.iii. Logical name: new_latitude e.iv. Type: Decimal Number e.v. Precision: 5 e.vi. Minimum Value: -90 e.vii. Maximum Value: 90 e.viii. Save & Close f. Add the “Longitude” field f.i. Click New f.ii. Set the Display Name to “Longitude” f.iii. Logical name: new_longitude f.iv. Type: Decimal Number f.v. Precision: 5 f.vi. Minimum Value: -180 f.vii. Maximum Value: 180 f.viii. Save & Close g. Add the “Location” field g.i. Click New g.ii. Set the Display Name to “Location” g.iii. Logical name: new_location g.iv. Type: Single Line of Text g.v. Format: Text g.vi. Save & Close h. Add the “Phone Number” field h.i. Click New h.ii. Set the Display Name to “Phone Number” h.iii. Logical name: new_phonenumber h.iv. Type: Single Line of Text h.v. Format: Text h.vi. Save & Close i. Add the “Priority” field i.i. Click New i.ii. Set the Display Name to “Priority” i.iii. Logical name: new_priority i.iv. Type: Option Set i.v. Choose Use Existing Option Set i.vi. Option Set: Service Request Priority i.vii. Save & Close j. Add the “Regarding Contact” field j.i. Click New j.ii. Set the Display Name to “Regarding Contact” j.iii. Logical name: new_regardingcontact j.iv. Type: Lookup j.v. Target Record Type: Contact j.vi. Relationship Name: new_specialrequest_regardingcontact j.vii. Save & Close k. Add the “Regarding Lead” field k.i. Click New k.ii. Set the Display Name to “Regarding Lead” k.iii. Logical name: new_regardinglead k.iv. Type: Lookup k.v. Target Record Type: Lead k.vi. Relationship Name: new_specialrequest_regardinglead k.vii. Save & Close l. Add the “Scheduled Date” field l.i. Click New l.ii. Set the Display Name to “Scheduled Date” l.iii. Logical name: new_scheduleddate l.iv. Type: Date and Time l.v. Format: Date and Time l.vi. Save & Close m. Add the “Incident Date” field m.i. Click New m.ii. Set the Display Name to “Incident Date” m.iii. Logical name: new_incidentdate m.iv. Type: Date and Time m.v. Format: Date and Time m.vi. Save & Close n. Add the “Service Request” field n.i. Click New n.ii. Set the Display Name to “Service Request” n.iii. Logical name: new_servicerequest n.iv. Type: Lookup n.v. Target Record Type: Service Request n.vi. Relationship Name: new_specialrequest_servicerequest n.vii. Save & Close o. Add the “Service Request Number” field o.i. Click New o.ii. Set the Display Name to “Service Request Number” o.iii. Logical name: new_servicerequestnumber o.iv. Type: Single Line of Text o.v. Format: Text o.vi. Save & Close p. Add the “Service Status” field p.i. Click New p.ii. Set the Display Name to “Service Status” p.iii. Logical name: new_servicestatus p.iv. Type: Option Set p.v. Choose Use Existing Option Set p.vi. Option Set: Service Status p.vii. Save & Close q. Add a (custom) Description field q.i. Click New q.ii. Set the Display Name to “Description” q.iii. Logical name: new_description q.iv. Type: Multiple Lines of Text q.v. Save & Close 9. From the Special Request entity you have just created (either the window that is still open or, if you closed it – by navigating to the entity in the solution window) Click Forms; it is now time to create the CRM form that will be used to render the service request on the portal. 10. Open the Main Information Form 11. Place all of the fields that you created earlier onto the form. a. Place the Location and Description fields in the “General” section of the “General” Tab. b. Click on the location field and click Change Properties c. Click on the Formatting Tab and click Two Columns, then click OK d. Click on the description field and click Change Properties e. Click on the Formatting Tab and click Two Columns f. Give the field four rows, then click OK g. Add the Priority, Scheduled Date, and Closed Date fields to the General section h. Created a new section called “Contact Details” h.i. Select the “General” tab h.ii. Click the Insert tab h.iii. Click Two Columns h.iv. Click on the new section to select it h.v. On the home tab, click Change Properties h.vi. Set the label to “Contact Details” h.vii. Click “Show the label of this section on the form h.viii. Click “Show a line at the top of the section” h.ix. Click OK i. Add the First Name, Last Name, Email Address, Regarding Contact and Phone Number fields to the Contact Details Section you just created 12. Note that we have not added the Service Request, Service Request Number, Latitude, and Longitude fields on the form. These may be placed in the header or footer. To edit the header, on the Home tab, click “header”. To edit the footer, on the home tab, click “footer” 13. Click Save 14. Now Click Save As and Name it Web Form – we will not customize it to suit what is needed on the portal 15. Remove the Notes Tab form the Form 16. Remove or Hide the following fields from the form (to hide a field, right-click on it and uncheck “Visible by Default” and check “field is read only”): a. Priority b. Scheduled Date and Closed Date c. Regarding Contact 17. Publish all Customizations The first step in this process is done, we now need to complete exercise 3 before the new service request type is surfaced on the portal. Exercise 3: Create the Web Form and Service Request Type

1. In the main CRM navigation console, click Settings 2. Under the “portals” subsection, navigate to “Service Request Types” 3. Click New 4. Enter all the fields for the Service Request Type definition: a. Name: Special Request b. Entity Name: Special Request (new_specialrequest) c. Auto Numbering Definition: Service Request Number d. Primary Field Name: new_name e. Service Request Field Name: new_servicerequest f. Service Request Number Field Name: new_servicerequestnumber g. Service Status Field Name: new_servicestatus h. Priority Field Name: new_priority i. Incident Date Field Name: new_incidentdate j. Scheduled Date Field Name: new_scheduleddate k. Closed Date Field Name: new_closeddate l. Location Field Name: new_location m. Latitude Field Name: new_latitude n. Longitude Field Name: new_longitude o. Contact/Lead Behavior: Create Contact p. Regarding Contact Field Name: new_contact q. First Name Field Name: new_firstname r. Last Name Field Name: new_lastname s. Email Field Name: new_email t. Phone Number Field Name: new_phonenumber 5. Click the Web Form lookup Window 6. Click New 7. Enter “Special Request Web Form” 8. Set “Start New Session On Load” to true 9. Click Save 10. Click the Start Step Lookup window 11. Click New 12. Give the Step the following Fields: a. Name: Load Special Request Web Form b. Web Form: Special Request Web Form c. Type: Load Form d. Target Entity Logical Name: Special Request (new_specialrequest) e. Mode: Insert f. Form Name: Web Form 13. Click Save 14. Click the Next Step Lookup Window 15. Click New 16. Give the Step the following Fields: a. Name: Load Success Message b. Web Form: Special Request Web Form c. Type: Load Form d. Target Entity Logical Name: Special Request (new_specialrequest) e. User Control Path: ~/Areas/Service311/Controls/WebFormServiceRequestSuccess.ascx f. Source Type: Result From Previous Step g. Move Previous Permitted: False 17. Save & Close 18. Click OK 19. Save & Close 20. Click OK 21. We now need to associate the Web Form with a web page 22. Click Web Pages on the left-hand side navigation 23. Click Add New Web Page 24. Give the Web Page the following Attributes: a. Name: Special Request b. Website: Government Portal c. Partial Url: special-request d. Page Template: Web Form e. Publishing State: Published f. Web Form: Special Request Web Form g. Parent Page: Service Requests Listing 25. Save & Close 26. Click OK 27. Save & Close The only step remaining before the service request can be surfaced on the portal is to register the Plugin using the Plugin registration Tool, available with the Microsoft CRM SDK: 1. Download the latest Microsoft CRM SDK and install 2. Under your CRM SDK install folder, navigate to sdk > tools > pluginregistration 3. Open pluginregistrationtool.sln in VS 2012 4. Rebuild all 5. Navigate to the bin > Debug folder and run PluginRegistration.exe 6. Use the following connection information to navigate to your CRM org: 7. Label: New Connection 8. Enter your Discovery URL; to find this URL a. Open IE b. Navigate to the URL of the CRM trial you created in preparation for this training course and log in c. Navigate to Settings > Customizations > Developer resources > Service Endpoints d. Under Discovery Service you will find a URL; in Websitecopy.exe choose from the dropdown the URL that matches your discovery URL. For example https://disco.crm.dynamics.com/ 9. Enter your credentials and click Next 10. Double-Click on your CRM Organization on the left-hand side navigation 11. Locate the Adxstudio.Xrm.Plugins.Service311 plugin assembly 12. Expand this assembly and select the Adxstudio.Xrm.Plugins.Service311.CustomServiceRequestGeoAsyncPlugin 13. Select Register > Register New Step 14. Fill in the following fields: a. Message: Create b. Primary Entity: new_specialrequest c. Choose Post-operation for the Pipeline stage of execution d. Choose Asynchronous as the execution mode e. Check “Delete AsyncOperation if StatusCode = Successful” 15. Select Register > Register New Step 16. Fill in the following fields: a. Message: Update b. Primary Entity: new_specialrequest c. Choose Post-operation for the Pipeline stage of execution d. Choose Asynchronous as the execution mode e. Check “Delete AsyncOperation if StatusCode = Successful” 17. Select the Adxstudio.Xrm.Plugins.Service311.NewCustomServiceRequestPlugin 18. Select Register > Register New Step 19. Fill in the following fields: a. Message: Create b. Primary Entity: new_specialrequest c. Choose Pre-operation for the Pipeline stage of execution d. Choose Synchronous as the execution mode 20. Select the Adxstudio.Xrm.Plugins.Service311.UpdateCustomServiceRequestPlugin 21. Select Register > Register New Step 22. Fill in the following fields: a. Message: Update b. Primary Entity: new_specialrequest c. Choose Post-operation for the Pipeline stage of execution d. Choose Synchronous as the execution mode

We can now actually TEST our service request!

1. Rebuild/Refresh the cache of Government Portal 2. Navigate to the portal in your browser and sign in as System Administrator 3. Create a Special request, just like you did in exercise 1 of this chapter. 145. Chapter 14: Portal Structure

Exercise 1: Add forums to Basic Portal

In this exercise, we will add forums to basic portal.

1. In CRM, navigate to Portals

2. Open up the Basic Portal

3. Navigate to Page Templates

4. Click Add New Page Template

5. Give the Page Template the following attributes:

a. Name: Forum

b. Website: Basic Portal

c. Rewrite Url: ~/Areas/Forums/Pages/Forum.aspx

6. Click Save & Close

7. Click Add New Page Template

8. Give the Page Template the following attributes:

a. Name: Forum Thread

b. Website: Basic Portal

c. Rewrite Url: ~/Areas/Forums/Pages/ForumThread.aspx

9. Click Save & Close

Portal:

10. Rebuild the MasterPortal project

11. Navigate to the Portal

12. Log in as administrator if you are not already logged in.

13. Navigate to the home page by clicking the house icon in the primary navigation

14. Locate the front-side editing panel on the upper-right hand corner 15. Click New > Child Page

16. Give the page the following attributes:

a. Name: Forums

b. Partial URL: forums

c. Page Template: Page

d. Publishing State: Published

e. Comment Policy: None

17. Click Save

18. You will now be redirect to the Forums Page. Before you do anything with this page, add a Web Link to the Primary Navigation

19. Click the Edit button that appears when you mouse over the primary navigation

20. Add a new Web Link by clicking the “+” icon

21. Attributes:

a. Name: Forum

b. Page: Forums

c. Publishing State: Published

22. Click Save

23. On the “Forums” page, click New > Child Forum

24. Give the new forum the following attributes:

a. Name: Example Forum

b. Partial URL: example-forum

c. Forum Template: Forum

d. Thread Template: Forum Thread

e. Publishing State: Published

25. Click Save

26. You may now use the forum. Try creating a new thread.

146. Chapter 15: ASP.NET Web Controls For these exercises, we will working with the MasterPortal in both Visual Studio and CRM.

Exercise 1: Add a new Page Template

In this exercise we will add a new Page Template to your web project that can be used for future exercises in this chapter. The Page Template will be a fairly bare-bones template with minimal functionality, which we will add functionality to over the course of this chapter.

In VS 2012 1. Open Visual Studio 2012. 2. Select File, Open Project. 3. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. 4. Select AdxstudioPortals.sln then click the Open button. 5. In the Solution Explorer, expand the project: MasterPortal 6. Navigate to the pages folder 7. Right-click on the pages Folder and select Add > New Item 8. Choose Web Form using Master Page 9. Name it Example.aspx 10. Choose WebFormsContent.master as the master page. 11. Inside the “MainContent” tag; Copy and paste the following markup:

CRM 1. Navigate to Portals > Websites 2. Open the Basic Portal website entity in the CRM 3. Click Page Templates in the left-hand Side navigation 4. On the ribbon, click to Add a New Page Template 5. Complete the following Fields: a. Name: Example Template b. Website: Basic Portal c. Rewrite URL: ~/Pages/Example.aspx 6. Click Save 7. Click Web Pages in the left-hand side navigation 147. On the ribbon, click the Add New Web Page button. 148. Complete the following fields: ct. Name: Example Page cu. Website: Basic Portal cv. Parent Page: Home cw. Partial Url: example cx. Page Template: Example Template cy. Publishing State: Published cz. Copy: This is my example page da. Set the value of the Summary field to: This is the Summary 149. On the Ribbon, click the Save and Close button to save your changes 150. Select Web Link Sets 151. Open Primary Navigation 152. Click once on the Links grid on the form 153. Click the Add New Web Link button on the ribbon db. Name: Example dc. Page: Example Page dd. Publishing State: Published de. Click Save & Close 154. Now rebuild the project in VS2012 155. Navigate to the Portal and navigate to the new example page you just created Exercise 2: Add a Property Control

In this Exercise we will add a property control which will display an attribute from the current page.

Visual Studio 156. Navigate to the Pages folder. 157. Open Example.aspx you created earlier. 158. Copy the following markup:

PropertyName="Adx_Summary" EditType="text"

runat="server" />

159. And paste it beneath the control already on the page 160. Note that the only thing different between this control and the other control on this page is that the data is being drawn from the summary attribute of the web page rather than the adx_copy. 161. Save and rebuild. 162. Navigate to your portal 163. When the Example page loads, you should now see the title you added in Step 2 displayed just above the Example page copy. 164. Note the Datasource that both property controls on the page are data-binding to:

Exercise 3: Add CrmHyperLink and Snippet controls

In the exercise, we will use the CrnHyperlink control to create a link based on a site marker – one that will not break if the URL of its target page changes. Note that we are setting the text of this link by using the snippet expression builder – we save the usage of the front-side editable Snippet control for the experiement. CRM 1. Navigate to Basic Portal in the CRM 2. Create the News page as a child page of the home page if you have not already done so (this was done in an earlier exercise) Partial Url: news 3. Click on the Site Markers navigation item. 165. On the Ribbon, click the Add New Site Marker button. This site marker will specify the destination of the hyperlink that we will be placing on the page template (and the link will always point to that page) 166. Complete the following fields: df. Name: My News dg. Web Site: Basic Portal dh. Page: News 167. On the Ribbon, click the Save and Close button. 168. Click on the Content Snippets navigation item. 169. On the Ribbon, click the Add New Content Snippet button. This will specify the label on the Hyperlink. 170. Complete the following fields: di. Name: My News Link Title dj. Website: Basic Portal dk. Type: Text dl. Value: News 171. On the Ribbon, click the Save and Close button.

Visual Studio

172. Open Example.aspx. 173. Add the following markup on the line just below the Adx_Copy control:

174. Save your changes and rebuild the project. 175. Navigate to your basic portal, then navigate to the Example Page 176. When the Example page loads, you should now see a News hyperlink just below the home page copy. 177. Click on that link and the News page should display.

Experiment

1) Add a new snippet to the CRM and add a Snippet control to your page template. Make it front-side editable. Recall that the format of the Snippet Control is as follows:

2) What are some other uses of Snippets? How about Site Settings? Play around with the expression builders for both and share your results. Exercise 4: Add a Weblinks Control

Create the web link set in the CRM 1. Under Basic Portal, Click on the Web Link Sets navigation item. 178. On the Ribbon, click the Add New Web Link Set button. 179. In the Name field, enter: Blogs We Follow. 180. On the Ribbon, click the Save button. 181. Click the Web Links navigation item. 182. On the Ribbon, click the Add New Web Link button. 183. Complete the following fields: dm.Name: Mitch’s Blog dn. Web Link Set: Blogs We Follow do. Website: Basic Portal dp. External Url: http://blogs.infinite-x.net dq. Publishing State: Published dr. Display Order: 1 ds. Open in New Window: Yes dt. Leave the remainder of the fields at their default values. 184. On the Ribbon, click the Save and Close button. 185. On the Ribbon, click the Add New Web Link button. 186. Complete the following fields: du. Name: Basic Portal Homepage dv. Web Link Set: Blogs We Follow dw. Website: Basic Portal dx. Page: Home dy. Publishing State: Published dz. Display Order: 2 ea. Open in New Window: No eb. Leave the remainder of the fields at their default values. 187. On the Ribbon, click the Save and Close button. Visual Studio

188. Navigate to the Pages folder. 189. Open Example.aspx. 190. Copy and paste the following into the SidebarContent tag:

191. Save and rebuild the project. Navigate to the Portal. 192. Navigate to the example page, and when it loads you should now see a second set of links on the right side of the page. Exercise 5: Add a CrmSiteMapChildView Control

In this exercise, we will add a CrmSiteMapChildView which will render out all child pages of the current page. You will need to add child pages to the current page in order to see any.

Visual Studio

1. Navigate to the Basic Portal project. 6. Open Example.aspx 7. We will use a CrmSiteMapChildView to render the child nodes of the current entity of the site map (the current web page). The layout of the rendered nodes will be determined by the Item Template that we use. 8. Add the following code within the “ContentBottom” tag:

  • 9. Rebuild the project. Navigate to the Portal 10. When the example page is displayed, you should see hyperlinks and descriptions for each of the pages that are considered children of the Example page. To Begin, you likely won’t have any, so try adding some using front-side editing. 11. Exercise 7: Add a CrmMetadataDataSource control

    Visual Studio 1. Navigate to the Basic Portal project. In this exercise we will be binding a drop down list to our CrmMetadataDataSource 12. Open Example.aspx 13. Insert the following code within the “ContentBottom” tag:

    14. Build the project. Navigate to the Portal 15. When the home page is displayed, you should see a drop-down list containing customer satisfaction codes from the Case entity within CRM. 193. Chapter 16: Managed Forms

    Exercise 1: Edit a CRM Form for lead

    In this exercise, we will set up a CRM form which we will later use to demonstrate the functionality for the CrmEntityFormView control, the Entity Form feature, and the Web Form feature.

    Please perform the following: In CRM, first we will create the CRM form itself: 1. Open Internet Explorer and navigate to your CRM online trial org 194. Navigate to the Settings Area of the Site Map 195. Click Customizations 196. Click Customize the System 197. Select Lead from the list of entities on the left navigation of the solution editor window. 198. Click Forms 199. Open the form titled Web Form 200. Click to Save As… 201. Name the form New Contact Us Form 202. Remove the following fields from the form: Street 1, City, State/Province, ZIP/Postal Code, Country/Region, Description 203. Save and Close the form again. 204. Reorder the forms so that the new form you create is not the default form: ec. Click Form Order ed. Click Main Form Set ee. Move the newly form to the bottom of the list ef. Click OK 205. Click Publish All Customizations – if this option isn’t shown, click to “information on the left-hand side of the main solution window Exercise 2: Create a Managed Form on the Portal

    In this exercise, we will utilize the CrmEntityFormView control to render our Contact Us form on the portal.

    1. Navigate to Portals – we will now add the page to the website that will render this form 206. Open the Basic Portal website. 207. Create a new Page Template for your form: eg. Click Page Templates eh. Click New ei. Specify the Name as Managed Forms Contact Us ej. Website: Basic Portal ek. Specify the Rewrite URL as ~/Pages/CrmEntityFormViewContactUs.aspx (we will create this in the web project later) el. Click Save & Close 208. Create a new Web Page using this template: em. Click Web Pages en. Click New eo. Specify the Name as Managed Forms Contact Us ep. Select the appropriate Website eq. Select the Home page as the Parent Page er. Specify managed-forms-contact-us as the partial URL es. Select the Managed Forms Contact Us Page Template created earlier et. Select Published as the publishing state eu. Click Save & Close 209. Navigate to Web Link Sets 210. Click Primary Navigation 211. Click Web Links 212. Click New 213. Give the web link the follow values: ev. Name: Managed Contact Us ew. Page: Managed Forms Contact Us ex. Publishing State: Published 214. Save & Close

    In Visual Studio 215. Open Visual Studio 2012. 216. Select File, Open Project. 217. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. 218. Select AdxstudioPortals.sln then click the Open button. 219. In the Solution Explorer, expand the project: MasterPortal. 220. Create a new ASP.NET Web Form using Master Page in the ~/pages folder 221. Use the WebForms.master page 222. Save the file as “CrmEntityFormViewContactUs.aspx” in Pages folder contained in the root of the project. 223. Replace the markup of the page with the following:

    224. Also add the following using Statements, to the using declarations at the top of the code- behind:

    using Adxstudio.Xrm.Web.UI.WebControls;

    using Microsoft.Xrm.Portal.Web.UI.WebControls; 225. Now add the following method to the code behind. This event handler is triggered when the form has successfully inserted the new record upon form submission: protected void OnItemInserted(object sender, CrmEntityFormViewInsertedEventArgs e) { ContactForm.Visible = false; ConfirmationMessage.Visible = true; } 226. Build the project.

    Let’s try out the form in the portal: 227. Navigate to the Basic Portal. 228. Navigate to the Managed Form Contact Us page on the portal. You should now see a form resembling the one you created in CRM. 229. Fill in the form ey. First name: John ez. Last Name: Doe fa. Remaining values can be whatever you wish

    CRM: 2. View the Submitted Leads in the CRM fb. Navigate to Sales fc. Click Leads fd. Find the John Doe record and open it fe. Note the lead created matches the data previously entered though the portal. 230. Chapter 17: Managed Lists

    Exercise 1: Add a CrmDataSource Control

    Visual Studio 1. Open the Basic Portal Project 16. Open Example.aspx 17. We will use fetchXml to establish our data source: a CRM query. We will then databind our gridview to the results of this query 18. Enter the following within the “ContentBottom” tag:

    19. Rebuild the project. Navigate to the Portal 20. On the Example page, you should see a GridView showing the name, city, and phone number of all of the active Accounts within CRM

    Exercise 3: Render a grid using the SavedQueryColumnsGenerator

    1. Open Visual Studio 2012. 231. Select File, Open Project. 232. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. 233. Select AdxstudioPortals.sln then click the Open button. 234. In the Solution Explorer, expand the project: MasterPortal. 235. Create a new ASP.NET Web Form using Master Page in the ~/pages folder 236. Use the WebForms.master page 237. Name it LeadQueryView.aspx 238. Replace the markup of the page with the following:

    239. Change the class definition of the page so that it inherits from PortalPage: public partial class LeadQueryView : PortalPage 240. Also add the following using Statements, to the using declarations at the top of the code- behind:

    using Adxstudio.Xrm.Web.UI;

    using Adxstudio.Xrm.Cms; 241. Add the following Code to the Page_Load method: var leads = ServiceContext.LeadSet; var columnsGenerator = new SavedQueryColumnsGenerator(ServiceContext, "lead", "All Leads");

    LeadList.DataKeyNames = new[] { "leadid" }; LeadList.DataSource = columnsGenerator.ToDataTable(leads); LeadList.ColumnsGenerator = columnsGenerator; LeadList.DataBind();

    242. Build the project. In CRM:

    8. Navigate to Portals > Websites 9. Open the Basic Portal website entity in the CRM 10. Click Page Templates in the left-hand Side navigation 11. On the ribbon, click to Add a New Page Template 12. Complete the following Fields: a. Name: Lead Query View b. Website: Basic Portal c. Rewrite URL: ~/Pages/LeadQueryView.aspx 13. Click Save 14. Click Web Pages in the left-hand side navigation 243. On the ribbon, click the Add New Web Page button. 244. Complete the following fields: ff. Name: Lead List fg. Website: Basic Portal fh. Parent Page: Home fi. Partial Url: lead-list a. Page Template: Lead Query View fj. Publishing State: Published 245. On the Ribbon, click the Save and Close button to save your changes 246. Select Web Link Sets 247. Open Primary Navigation 248. Click once on the Links grid on the form 249. Click the Add New Web Link button on the ribbon fk. Name: Leads fl. Page: Lead List fm. Publishing State: Published fn. Display Order: 4 fo. Click Save & Close 250. Now rebuild the project in VS2012 251. Navigate to the Portal and navigate to the new example page you just created Exercise 4: Add Edit capability to your grid using Site Markers and an Entity Form

    In this exercise, we are going to build on what we’ve done and add edit capability to our grid. We will do so by using the Entity Form feature and creating a web page with an entity form in the CRM. We will then hook this up via a site marker and linking the rows of our grid to this site maker, passing the ID of the element to the form which will allow us to edit.

    In CRM: 1. Navigate to Portals >Websites > Basic Portal 2. Click Web Pages 3. Create a new Web Page containing the Entity Form for displaying a case: 4. Name:Lead Form 5. Parent Page: Lead List 6. Partial Url: view-lead 7. Page Template: Page 8. Publishing State: Published 9. Open The Entity Form lookup window 10. In the lookup window, click New 11. We are now setting up the Entity Form. Give it the following data: a. Name: Lead Form b. Entity Name: Lead (lead) c. Form Name: New Contact Us Form d. Mode: Edit e. Record Source Type: Query String f. Record ID Query String Parameter Name: id 12. Click Save & Close 13. Click OK to set the Entity Form on the web page 14. Click Save 15. Click Site Markers 16. Click Add New Site Marker 17. Set the Name to “Lead Details” 18. Set the Website to Basic Portal 19. Ensure the Page is set to Lead Form 20. Save & Close In VS 2012 2. Open Visual Studio 2012. 252. Select File, Open Project. 253. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. 254. Select AdxstudioPortals.sln then click the Open button. 255. In the Solution Explorer, expand the project: MasterPortal. 21. Open LeadQueryView.aspx and then navigate to its code behind 22. Also add the following using Statements, to the using declarations at the top of the code-behind:

    using Microsoft.Xrm.Portal.Web; 23. Underneath the Page_Load method, add the following methods:

    protected void LeadList_OnRowDataBound(object sender, GridViewRowEventArgs e) {

    if (e.Row.RowType != DataControlRowType.DataRow) { return; }

    var dataKey = LeadList.DataKeys[e.Row.RowIndex].Value;

    e.Row.Cells[1].Text = string.Format(@" {1}", LeadDetailsUrl(dataKey), e.Row.Cells[1].Text);

    } protected string LeadDetailsUrl(object id) { var page = ServiceContext.GetPageBySiteMarkerName(Website, "Lead Details"); var url = new UrlBuilder(ServiceContext.GetUrl(page)); url.QueryString.Set("id", id.ToString()); return url.PathWithQueryString; } 24. Now view the markup and change the GridView control to the following:

    25. Save all and rebuild the project 26. Navigate to the Portal and Sign In 27. Navigate to your case view. Note that you can now click the id of the case and view the case form in edit mode!

    Experiment

    1) Add a “Create new” Button to the page so that you can click and create a new case! 256. Chapter 18: Portal Development Basics

    Exercise 1: Query CRM using early-bound classes

    1. If you have already done the chapter 15 exercises, open the Example.aspx page you created earlier, and skip to Step 2. Otherwise complete the following: a. Open Visual Studio 2012 fp. Select File, Open Project fq. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. fr. Select AdxstudioPortals.sln then click the Open button fs. In the Solution Explorer, expand the project: MasterPortal fs.i. Create a new ASP.NET Web Form using Master Page in the ~/pages folder ft. Use the WebForms.master page fu. Name it Example.aspx 257. Inside the “MainContent” tag; copy and paste the following markup:

    258. Change the class definition of the page so that it inherits from PortalPage: public partial class Example : PortalPage 259. Add the following Code to the Page_Load method: var leads = XrmContext.LeadSet; var firstLead = leads.FirstOrDefault(); FirstLeadLabel.Text = firstLead.FullName;

    260. Save all.

    In CRM:

    15. Create the corresponding Page Template and Web Page in the CRM, fi you did not already do so in the Chapter 15 exercises. If you did the exercises in chapter 15, skip this step and go to step 8. a. Navigate to Portals > Websites b. Open the Basic Portal website entity in the CRM c. Click Page Templates in the left-hand Side navigation d. On the ribbon, click to Add a New Page Template e. Complete the following Fields: e.i. Name: Example Template e.ii. Website: Basic Portal e.iii. Rewrite URL: ~/Pages/Example.aspx f. Click Save g. Click Web Pages in the left-hand side navigation fv. On the ribbon, click the Add New Web Page button. fw. Complete the following fields: fw.i. Name: Example Page fw.ii. Website: Basic Portal fw.iii. Parent Page: Home fw.iv. Partial Url: example fw.v. Page Template: Example Template fw.vi. Publishing State: Published fw.vii. Copy: This is my example page fw.viii. Set the value of the Summary field to: This is the Summary fx. On the Ribbon, click the Save and Close button to save your changes fy. Select Web Link Sets fz. Open Primary Navigation ga. Click once on the Links grid on the form gb. Click the Add New Web Link button on the ribbon gb.i. Name: Example gb.ii. Page: Example Page gb.iii. Publishing State: Published gb.iv. Display Order: 3 gb.v. Click Save & Close 261. Now rebuild the project in VS2012 262. Navigate to the Portal and navigate to the new example page you just created Experiment

    1) Currently you are render the name of the first lead that appears in the query but you are not performing any actions on this lead. Place a button in the markup of the page. Add a button click handler that takes text of your choice to change the first name of the Lead. You can draw this string value from a textbox or hard-code it. Because you can dot-though it should be easy to determine that this will involve code that looks like this:

    firstLead.FirstName = chosenName; Furthermore, you can save your changes to the lead record using the following:

    XrmContext.UpdateObject(firstLead);

    XrmContext.SaveChanges();

    2) Practice more CRM queries and more CRUD operations using the auto-generated code classes. You ability to dot-through affords you great speed in development. Play around with the options. Exercise 2: Query CRM using late-bound methods

    1. Open Example.aspx 263. Add the following Code to the Page_Load method: var dynamicLeads = ServiceContext.CreateQuery("lead"); var firstDynamicLead = dynamicLeads.FirstOrDefault(); FirstLeadLabel.Text = firstDynamicLead.GetAttributeValue("fullname"); 264. Save all. 265. When you rebuild the project and reload the page, you will notice it will work the same way as before – we are performing the exact same set of operations, except we are using late- bound dynamic methods now.

    Experiment

    1) In the experiment for the previous exercise, we added an additional CRUD operation to the lead record – we set it’s name using the accessor property right on the early bound class. For this experiment, please do the same thing, but this time you will need to do this dynamically using the following:

    firstDynamicLead.Attributes["firstname"]= chosenName;

    2) Now try using a site setting to set the last name of the lead upon the button being clicked – just like you set the first name, but instead of hard-coding what you set the name to, you will create a site setting in the CRM called “firstLead/LastNameSetTo” or something to that effect, and you will use the ServiceContext to get the value of this site setting and set the lead’s last name to whatever the value of this site setting is set to in the CRM using the following extension method:

    var chosenLastName = ServiceContext.GetSiteSettingValueByName(Website, "firstLead/LastNameSetTo");

    Note that you will need to include the following using statement:

    using Adxstudio.Xrm.Web.Cms; Exercise 3: Add a Comment Control

    CRM 1. Navigate to Portals > Websites > Basic Portal 2. Click on the Web Pages navigation link on the left-hand side 3. Open Example Page that you created earlier 4. Change the Comment Policy to Open. Visual Studio 266. Open Visual Studio 2012. 267. Select File, Open Project. 268. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. 269. Select AdxstudioPortals.sln then click the Open button. 270. In the Solution Explorer, expand the project: MasterPortal. 271. Navigate to the Pages folder. 272. Open Example.aspx you created earlier. 273. Add the following declaration:

    <%@ Register src="~/Controls/Comments.ascx" tagname="Comments" tagprefix="adx" %> 274. In the location where you would like your page rating control displayed, add the following:

    275. Rebuild the project and test the portal. Exercise 4: Add a Rating Control

    CRM 5. Navigate to Portals > Websites > Basic Portal 6. Click on the Web Pages navigation link on the left-hand side 7. Open Example Page that you created earlier 8. Change the Comment Policy to Open. Visual Studio 276. Open Visual Studio 2012. 277. Select File, Open Project. 278. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. 279. Select AdxstudioPortals.sln then click the Open button. 280. In the Solution Explorer, expand the project: MasterPortal. 281. Navigate to the Pages folder. 282. Open Example.aspx you created earlier. 283. Open your page template and add the following declaration:

    <%@ Register src="~/Controls/MultiRatingControl.ascx" tagname="MultiRatingControl" tagprefix="adx" %> 284. In the location where you would like your page rating control displayed, add the following:

    285. Rebuild the project and test the portal. 286. Chapter 19: Ads and Polls

    Exercise 1: Add an Advertisement to the Basic Portal

    CRM 1. Navigate to the Basic Portal Website Entity 2. Click the Ad Placement navigation link. 3. On the Ribbon, click the Add New Ad Placement button. 4. Enter the following properties: a. Name: Fine Books 5. On the Ribbon, click the Save button. 6. Click the Ads navigation link. 7. On the Ribbon, click the Add Existing Ad button. 8. When the Lookup dialog is displayed, click the New button. 9. Complete the following fields: a. Name: Fine Books b. Website: Basic Portal c. Publishing State: Published d. Redirect URL: http://www.amazon.com e. Open in New Window: Checked f. Title: Fine Books g. Copy: Fine books and sundries 10. On the Ribbon, click the Save and Close button. 11. When you return to the Lookup dialog, click the OK button.

    Visual Studio

    12. Open Example.aspx. 13. Insert the following control into the MainContent content control:

    14. Save and Run the project. 15. When the Basic Portal home page is displayed, you should see an advertisement for Fine Books located at the bottom of the content area. Exercise 2: Add an Poll to the Basic Portal

    CRM 1. Click the Poll Placement navigation link. 16. On the Ribbon, click the Add New Poll Placement button. 17. Enter the following properties: a. Name: Installation Timeframe b. The remaining fields are fine with their default values. 18. On the Ribbon, click the Save button. 19. Click the Polls navigation link. 20. On the Ribbon, click the Add Existing Poll button. 21. When the Lookup dialog is displayed, click the New button. 22. Complete the following fields: a. Name: Installation Timeframe b. Question: When will you be installing Dynamics CRM 2011? c. Submit button label: Vote 23. On the Ribbon, click the Save button. 24. Click the Options navigation link. 25. On the Ribbon, click the Add New Poll Options button. 26. Complete the following properties: a. Name: Immediately b. Answer: Immediately 27. On the Ribbon, click the Save and New button. 28. Complete the following properties: a. Name: 6 months b. Answer: 6 months 29. On the Ribbon, click the Save and New button. 30. Complete the following properties: a. Name: 1 year b. Answer: 1 year 31. On the Ribbon, click the Save and Close button. 32. On the Ribbon, click the Save and Close button. 33. When you return to the Lookup dialog, click the Ok button.

    Visual Studio

    34. Open Example.aspx. 35. Insert the following control into the MainContent content control:

    36. Save and Run the project. 37. When the Basic Portal home page is displayed, you should see an Installation Timeframe poll located at the bottom of the content are 287. Chapter 20: MVC

    Exercise 1: Use the Attribute Helpers

    1. If you have already done the chapter 15 exercises, open the Example.aspx page you created earlier, and skip to Step 2. Otherwise complete the following: b. Open Visual Studio 2012. gc. Select File, Open Project. gd. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples. ge. Select AdxstudioPortals.sln then click the Open button. gf. In the Solution Explorer, expand the project: MasterPortal. gf.i. Create a new ASP.NET Web Form using Master Page in the ~/pages folder gg. Use the WebForms.master page gh. Name it Example.aspx 288. Change the class definition of the page so that it inherits from PortalPage: public partial class Example : PortalPage 289. Add the following declaration to the top of the markup:

    <%@ Import namespace="Adxstudio.Xrm.Web.Mvc.Html" %> 290. Add the following to the markup inside the MainContent content placeholder:

    MVC Attribute Control:

    <%= Html.Attribute("adx_copy") %> 291. Save all.

    In CRM:

    16. Create the corresponding Page Template and Web Page in the CRM, fi you did not already do so in the Chapter 15 exercises. If you did the exercises in chapter 15, skip this step and go to step 8. a. Navigate to Portals > Websites b. Open the Basic Portal website entity in the CRM c. Click Page Templates in the left-hand Side navigation d. On the ribbon, click to Add a New Page Template e. Complete the following Fields: e.i. Name: Example Template e.ii. Website: Basic Portal e.iii. Rewrite URL: ~/Pages/Example.aspx f. Click Save g. Click Web Pages in the left-hand side navigation gi. On the ribbon, click the Add New Web Page button. gj. Complete the following fields: gj.i. Name: Example Page gj.ii. Website: Basic Portal gj.iii. Parent Page: Home gj.iv. Partial Url: example gj.v. Page Template: Example Template gj.vi. Publishing State: Published gj.vii. Copy: This is my example page gj.viii. Set the value of the Summary field to: This is the Summary gk. On the Ribbon, click the Save and Close button to save your changes gl. Select Web Link Sets gm.Open Primary Navigation gn. Click once on the Links grid on the form go. Click the Add New Web Link button on the ribbon go.i. Name: Example go.ii. Page: Example Page go.iii. Publishing State: Published go.iv. Display Order: 3 go.v. Click Save & Close 292. Now rebuild the project in VS2012 293. Navigate to the Portal and navigate to the new example page you just created.

    105 Experiment

    1) Experiment with the different ways to use the Attribute Helpers:

    <%= Html.Attribute(Html.Website(), "adx_name") %> <%= Html.Attribute(p => p.Adx_name) %> <%= Html.TextAttribute("adx_title") %> <%= Html.HtmlAttribute("adx_summary") %> <%= Html.AttributeLiteral("adx_copy") %> Exercise 2: Use the Site Setting Helpers

    IN CRM 1. Navigate to Portals > Websites > Basic Portal 294. Navigate to Site Settings 295. Create a new Site Setting: gp. Name: Example Boolean Setting gq. Value: true or false gr. Save & Close In Vs 2012

    296. Open Example.aspx 297. Add the following to the markup: <% if (Html.BooleanSetting("Example Boolean Setting") ?? false) %> <% { %>

    The Boolean Setting is set to true!

    <% } else { %>

    The Boolean Setting is set to false!

    <% } %> 298. Save all 299. Rebuild the project 300. Browse to the portal and open up the example page

    Experiment

    1) Try creating a setting that takes an integer value and use the Html.IntegerSetting() helper to get and use this value.

    107 Exercise 3: Use the Site Marker Helpers

    1. If you have not already done so, you will create a “News” page and a site marker that points to this page. This was completed in a previous exercise. If you have done all exercises up to this point, skip past this step. a. Navigate to Basic Portal in the CRM b. Create the News page as a child page of the home page if you have not already done so (this was done in an earlier exercise) Partial Url: news c. Click on the Site Markers navigation item. gs. On the Ribbon, click the Add New Site Marker button. This site marker will specify the destination of the hyperlink that we will be placing on the page template (and the link will always point to that page) gt. Complete the following fields: gt.i. Name: My News gt.ii. Web Site: Basic Portal gt.iii. Page: News gu. On the Ribbon, click the Save and Close button. 301. In VS 2012, Open Example.aspx 302. Add the following to the markup of the page, In the “Main Content” content area:

    <%= Html.SiteMarkerLink("My News") %> 303. Save and rebuild the project then browse to see the results Exercise 4: Use the Snippet Helpers

    1. In the CRM, open Portals > Websites > Basic Portal 304. Navigate to Content Snippets 305. Create a new Content Snippet: gv. Name: Example Content Snippet gw. Value: This is a Snippet. gx. Save & Close

    In VS 2012

    306. Open Example.aspx 307. Add the following to the markup of the page, In the “Main Content” content area:

    %= Html.TextSnippet("Example Content Snippet") %> 308. Save all, rebuild, and browse to see the results.

    Experiment

    1) Experiment with different ways to use the Snippet Helpers according to the usages below. You can also create new Content snippets and try different values for those snippets.

    <%= Html.HtmlSnippet("Example Content Snippet") %> <%= Html.Snippet("Example Content Snippet") %> <%= Html.SnippetLiteral("Example Content Snippet") %>

    109 Exercise 5: Use the Web Link Helpers

    In this exercise, we will Utilise the MVC Web Links Helpers to render the links of a Web Link Set in the CRM.

    1. If you have not done all the exercises from chapter 15, you may skip this step, as you will be creating a new Web Link Set, which you would have already done in Chapter 15. If you have done this already, skip to Step 2. a. Under Basic Portal, Click on the Web Link Sets navigation item. gy. On the Ribbon, click the Add New Web Link Set button. gz. In the Name field, enter: Blogs We Follow. ha. On the Ribbon, click the Save button. hb. Click the Web Links navigation item. hc. On the Ribbon, click the Add New Web Link button. hd. Complete the following fields: hd.i. Name: Mitch’s Blog hd.ii. Web Link Set: Blogs We Follow hd.iii. Website: Basic Portal hd.iv. External Url: http://blogs.infinite-x.net hd.v. Publishing State: Published hd.vi. Display Order: 1 hd.vii. Open in New Window: Yes hd.viii. Leave the remainder of the fields at their default values. he. On the Ribbon, click the Save and Close button. hf. On the Ribbon, click the Add New Web Link button. hg. Complete the following fields: hg.i. Name: Basic Portal Homepage hg.ii. Web Link Set: Blogs We Follow hg.iii. Website: Basic Portal hg.iv. Page: Home hg.v. Publishing State: Published hg.vi. Display Order: 2 hg.vii. Open in New Window: No hg.viii. Leave the remainder of the fields at their default values. hh. On the Ribbon, click the Save and Close button.

    In VS 2012

    309. Open Example.aspx 310. Add the following Code to the MainContent content placeholder area:

    <% foreach (var link in Html.WebLinkSet("Blogs We Follow").WebLinks) %> <% { %>

    <%= Html.WebLink(link) %>

    <% } %>

    311. Save and rebuild the project, then browse to see the result.

    Experiment

    1) Experiment with different ways to render Web Link Sets. Html.WebLinks is essentially equivalent to the web control. Html.WebLinksDropdown, on the other hand, gives more advancing rendering of bootstrap dropdowns for sub menus, etc. Play with the different options.

    111 Exercise 6: Add an MVC App

    In this exercise, we will create a bare-bones MVC app and anchor it in our portal via a site marker. This App will display an unordered, unstyled list of campaigns and simply output the description of each one. In the experiment, you will get the opportunity to expand on this functionality to create a more fully- featured MVC app.

    In CRM: 1. Navigate to Marketing 312. Click Campaigns on the left-hand side navigation 313. Click to Create a New Campaign 314. Give the Campaign the following values: hi. Name: My Campaign hj. Description: This is the description of my Campaign hk. Leave the remainder of the fields at their default values hl. Click Save & Close 315. Navigate to Portals > Websites 316. Open Basic Portal 317. Navigate to Web Pages 318. Create a new Web Page with the following values: hm.Name: Campaign View Area hn. Website: Basic Portal ho. Parent Page: Home hp. Partial Url: campaign-view hq. Page Template: Page hr. Publishing State: Published hs. Save but do not close the form 319. Navigate to Web Links on the left-hand side navigation 320. Click Add New Web Link 321. Give the Web link the following values: ht. Name: Campaign View Area hu. Web Link Set: Primary Navigation hv. Page: Campaign View Area hw. Publishing State: Published hx. Save & Close 322. Navigate to Site Markers on the left-hand navigation 323. Click Add New Site Marker 324. Give the Site Marker the following values: hy. Name: Campaign View Area hz. Website: Basic Portal ia. Page: Campaign View Area ib. Save & Close

    We have a Web page anchored by a site marker that will ‘host’ our MVC App. Let’s now build that MVC in VS 2012

    325. Right-Click on the Areas folder in the MasterPortal web project 326. Select New > Area 327. Enter MyCampaigns as the Area Name 328. Open MyCampaignsAreaRegistration.cs. This file was created when you created your new area. A RegisterArea( ) function should also have been created with an example route already wired up. 329. Include the following Using Statement: using Adxstudio.Xrm.Web.Mvc; 330. Replace the context.MapRoute( ) function with the following code: context.MapSiteMarkerRoute( "Campaign View Area", "Campaign View Area", "{action}/{id}", new { controller = "Campaigns", action = "Index", id = UrlParameter.Optional } ); 331. Right-click on the Models folder in your new Area 332. Select Add > New Item 333. Under Code, select Class 334. Name your class CampaignViewModel.cs 335. Add the following declarations to the top of the code file:

    113 using Microsoft.Xrm.Sdk; using Xrm;

    336. Add the following property to the new view model class you have created: public List Campaigns; 337. Right-click on the Controllers folder in your new Area 338. Select Add > Controller 339. Controller name: CampaignController 340. Add the following declarations to the top of the file: using Adxstudio.Xrm.Web.Mvc; using Site.Areas.MyCampaigns.Models; using Xrm;

    341. Replace the entire Index( ) ActionResult function with the following: public ActionResult Index() { var context = new XrmServiceContext();

    var campaigns = context.CampaignSet;

    var viewModel = new CampaignViewModel() { Campaigns = campaigns.ToList() };

    return View(viewModel); } 342. Right-click on the Views > Shared folder in your Area 343. Select New > View 344. Set Index as the name of your view 345. Set your view Engine to ASPX (C#) 346. Choose “Use a layout or master page” 347. For the master page, choose “~/MasterPages/Default.master” 348. Replace the entire contents of the Index.aspx file with the following: <%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.master" Inherits="System.Web.Mvc.ViewPage" %> <%@ OutputCache CacheProfile="User" %> <%@ Import Namespace="System.Web.Mvc.Html" %> <%@ Import Namespace="Adxstudio.Xrm.Web.Mvc.Html" %> <%= Html.HtmlAttribute("adx_copy") %>

      <% foreach (var campaign in Model.Campaigns) { %>
    • <%= campaign.Description %>
    • <% } %>
    349. Save all and Rebuild the project. 350. Brows to your campaign View Area in Basic Portal.

    115

    Recommended publications