exercises - Adxstudio Community

Developer Training Guide
Lab Workbook
Table of Contents
Chapter 1: Portals Overview ......................................................................................................................... 5
Chapter 2: Deployment ................................................................................................................................. 6
Exercise 1: Installing Adxstudio Portals .................................................................................................... 6
Exercise 2: Practice Using the WebsiteCopy tool ..................................................................................... 8
Chapter 3: CMS Components ..................................................................................................................... 10
Exercise 1: Add new web pages ............................................................................................................. 10
Chapter 4: Content Publishing .................................................................................................................... 13
Exercise 1: Add Web Pages using Front-Side Editing ............................................................................ 13
Experiment .......................................................................................................................................... 13
Chapter 5: Security ..................................................................................................................................... 14
Exercise 1: Configure Invitation Sign Up ................................................................................................ 14
Experiment .......................................................................................................................................... 15
Exercise 2: Configure Web Role and Assign Web Access Permissions .. Error! Bookmark not defined.
Chapter 6: Community Features ................................................................................................................. 20
Exercise 1: Add a Forum......................................................................................................................... 20
Exercise 2: Add a Forum Thread ............................................................................................................ 22
Exercise 3: Add an Idea Forum .............................................................................................................. 23
Exercise 4: Add an Idea .......................................................................................................................... 24
Exercise 5: Add a Blog ............................................................................................................................ 25
Exercise 6: Add a Blog Post.................................................................................................................... 26
Chapter 7: Portal Theming .......................................................................................................................... 27
Exercise 1: Edit the Copy of a Page Using Bootstrap Elements ............................................................ 27
Exercise 2: Roll a Custom Bootstrap Theme for your Portal .................................................................. 29
Chapter 8: Displaying Forms....................................................................................................................... 30
Exercise 1: Edit a CRM Form for lead .................................................................................................... 30
Exercise 2: Create a Managed Form on the Portal ................................................................................ 31
Exercise 3: Create an Entity Form on the Portal..................................................................................... 34
Exercise 4: Set Up a Web Form.............................................................................................................. 35
Exercise 5: Set up a Survey .................................................................................................................... 37
Experiment .......................................................................................................................................... 43
Chapter 9: Displaying Views ....................................................................................................................... 44
Exercise 1: Surface a CRM View as Entity List ...................................................................................... 44
Exercise 2: Add an Edit Form to the Leads List ...................................................................................... 46
Chapter 10: Event Management ................................................................................................................. 47
Exercise 1: Add Events to Basic Portal ................................................................................................... 47
Chapter 11: Customer Support ................................................................................................................... 48
Exercise 1: Manage Cases ..................................................................................................................... 48
Chapter 12: Service Requests .................................................................................................................... 49
Exercise 1: Create a new Service Request on the Portal ....................................................................... 49
Exercise 2: Create a new Service Request Entity .................................................................................. 50
Exercise 3: Create the Web Form and Service Request Type ............................................................... 55
Chapter 14: Portal Structure ....................................................................................................................... 59
Exercise 1: Add forums to Basic Portal ................................................................................................... 59
Chapter 15: ASP.NET Web Controls .......................................................................................................... 61
Exercise 1: Add a new Page Template ................................................................................................... 61
Exercise 2: Add a Property Control ......................................................................................................... 63
Exercise 3: Add CrmHyperLink and Snippet controls ............................................................................. 64
Experiment .......................................................................................................................................... 65
Exercise 4: Add a Weblinks Control ........................................................................................................ 66
Exercise 5: Add a CrmSiteMapChildView Control .................................................................................. 67
Exercise 7: Add a CrmMetadataDataSource control .............................................................................. 68
Chapter 16: Managed Forms ...................................................................................................................... 69
Exercise 1: Edit a CRM Form for lead .................................................................................................... 69
Exercise 2: Create a Managed Form on the Portal ................................................................................ 70
Chapter 17: Managed Lists ......................................................................................................................... 73
Exercise 1: Add a CrmDataSource Control ............................................................................................ 73
Exercise 2: Add a SavedQueryDataSource Control ................................. Error! Bookmark not defined.
Exercise 3: Render a grid using the SavedQueryColumnsGenerator .................................................... 75
Exercise 4: Use the Portal Context to determine the current user Contact .............Error! Bookmark not
defined.
Exercise 5: Add Edit capability to your grid using Site Markers and an Entity Form .............................. 77
Experiment .......................................................................................................................................... 78
Chapter 18: Portal Development Basics ..................................................................................................... 79
Exercise 1: Query CRM using early-bound classes ............................................................................... 79
Experiment .......................................................................................................................................... 80
Exercise 2: Query CRM using late-bound methods ................................................................................ 81
Experiment .......................................................................................................................................... 81
Exercise 3: Add a Comment Control ....................................................................................................... 82
Exercise 4: Add a Rating Control ............................................................................................................ 83
Chapter 19: Ads and Polls .......................................................................................................................... 84
Exercise 1: Add an Advertisement to the Basic Portal ........................................................................... 84
Exercise 2: Add an Poll to the Basic Portal............................................................................................. 85
Chapter 20: MVC ........................................................................................................................................ 87
Exercise 1: Use the Attribute Helpers ..................................................................................................... 87
Experiment .......................................................................................................................................... 88
Exercise 2: Use the Site Setting Helpers ................................................................................................ 89
Experiment .......................................................................................................................................... 89
Exercise 3: Use the Site Marker Helpers ................................................................................................ 90
Exercise 4: Use the Snippet Helpers ...................................................................................................... 91
Experiment .......................................................................................................................................... 91
Exercise 5: Use the Web Link Helpers ................................................................................................... 92
Experiment .......................................................................................................................................... 93
Exercise 6: Add an MVC App ................................................................................................................. 94
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.
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:
1. 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.
2. 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.
3. Enter a unique domain name for your trial (domainname.demo.adxstudio.com)
4. Enter the CRM organization URL for your CRM Online trial
5. Enter administrative username and password credentials.
6. Agree to the terms of use and click the Create Demo button.
7. Wait for an email that tells you that your environment has been configured.
8. 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.
2.
3.
4.
5.
6.
7.
8.
Navigate to community.adxstudio.com
Click the download link to download the latest Portals .msi file.
If you do not have an account, you will be asked to create one before you can download
Install the .msi file, to the default location (Program Files(x86)
Open IIS
Click Add Website…
Site Name: Basic Portal
For Physical Path, browse to C:\Program
Files(x86)\ADXSTUDIO\XrmPortals\6.x.xxxx\Samples\MasterPortal
9.
10.
11.
12.
Set the Port number for the website or specify a specific host name, and click OK
Ensure that the app pool for the portal is set to .NET framework version 4.0.
Open VS 2012
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:
<add name="Xrm" connectionString="ServiceUri=https://userdemo.crm.dynamics.com;
16. Open IE and browse to the website [email protected];
Password=*********;"/>
17. Open the web.config again
18. Modify the <portals> node under <Microsoft.xrm.portal> (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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
Navigate to C:\Program Files (x86)\ADXSTUDIO\XrmPortals\6.x.xxxx\Utilities
Open WebsiteCopy.exe
Select “XML File” as the source of the website you will be copying
Click Next to select the name of the XML file you will be importing.
Click Browse
Navigate to C:\Program Files (x86)\ADXSTUDIO\XrmPortals\6.x.xxxx\Samples
Choose Basic Portal.xml
Click Next
Click Next
We now choose the destination of the websitecopy; make sure Microsoft Dynamics CRM
server is selected.
Click Next
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/
Enter your credentials and click Next
Click Connect
Enter Imported Portal as the website name
Click Next
Click Create Website
In CRM
18.
19.
20.
21.
Once the utility is finished, navigate to CRM and refresh
Navigate to portals.
Open Imported Portal
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 <portals> node under <Microsoft.xrm.portal> (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 <portals> node under <Microsoft.xrm.portal> (near the bottom of the file) so that the
websiteName=“Basic Portal”
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Open Internet Explorer and navigate to your CRM online trial org.
Click the Portals area of the SiteMap (left-hand navigation).
Click Websites.
Click Basic Portal to open the Basic Portal website record.
Select Web Pages.
On the ribbon, click the Add New Web Page button.
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.
Click the Save and New button on the ribbon to save the record and open a new one.
When the new dialog is displayed, complete the following fields:
a. Name: News Article One
b. Website: Basic Portal
c. Parent Page: News
d. Partial Url: article01
e. Copy: Lorem Ipsum
f. Display Order: 10
g. Display Date: today’s date
h. Page Template: Page
i. Publishing State: Published
Click the Save and New button on the ribbon to save the record and open a new one.
When the new dialog is displayed, complete the following fields:
a. Name: News Article Two
b. Website: Basic Portal
c. Parent Page: News
d. Partial Url: article02
e. Copy: Dolor
f. Display Order: 11
g. Display Date: today’s date
h. Page Template: Page
i. Publishing State: Published
12. Click the Save and Close button on the ribbon to save the record and close the page.
13. Select Web Link Sets.
14. Open Primary Navigation.
15. Click once on the Links grid on the form.
16. Click the Add New Web Link button on the ribbon.
a. Name: News
b. Page: News
c. Publishing State: Published
d. Click Save & Close
In VS 2012:
17. Refresh the Adxstudio cache by resetting the Basic Portal in IIS or Rebuilding the Basic Portal
Project in VS 2012
18. Navigate to the Basic Portal website in IE
19. You will notice that News now appears on the primary navigation bar at the top of the page.
20. Click on News
21. Notice the Child links that appear. These are being generated by the “Page” Page Template.
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.
6. Complete the following properties:
a. Name: Example Content
b. Copy: This is the Example Content page
7. Leave the remainder of the properties at their default values.
8. Click the Save button to save your changes.
9. Move your mouse over the Primary Navigation and click the Edit button.
10. Click the Add button (green plus).
11. Complete the following properties:
a. Name: Example Content
b. Page: Example Content
12. Click the Save button to save the new navigation link.
13. Click the Save button to save your changes to the Primary Navigation.
14. After the page reloads, you should see your new pages on the Primary Navigation bar.
15. Navigate to Example Content page
16. 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)
17. 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.
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.
2.
3.
4.
Navigate to your Basic Portal website
If you are signed in, sign out
Click to Sign In
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.
2.
3.
4.
Navigate to Contacts via Workplace
Note the contact that was created.
Open up the contact
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.
7.
8.
9.
10.
Navigate to Portals
Open Basic Portal
Navigate to Site Settings on the left-hand navigation pane
Open the Authentication/Registration/Enabled Site Setting
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.
2.
3.
4.
5.
Navigate to Portals, Web Sites.
Open Basic Portal.
Click on the Web Pages navigation link on the left-hand side
On the Ribbon, click on the Add New Web Page button.
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:
i. Name: News
ii. Website: Basic Portal
iii. Parent Page: Home
iv. Partial Url: news
v. Display Date: today’s date
vi. Page Template: Page
vii. Publishing State: Published
viii. Copy: This is the news page.
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:
i. Name: News Article One
ii. Website: Basic Portal
iii. Parent Page: News
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
iv. Partial Url: article01
v. Page Template: Page
vi. Publishing State: Published
vii. Copy: Lorem Ipsum
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:
i. Name: News Article Two
ii. Website: Basic Portal
iii. Parent Page: News
iv. Partial Url: article02
v. Page Template: Page
vi. Publishing State: Published
vii. Copy: Dolor
viii. Display Order: 2
g. Click the Save and Close button on the ribbon to save the record and close the page.
Click the Web Roles navigation link.
On the Ribbon, click the Add New Web Role button.
Complete the following fields:
a. Name: News Editor
b. Website: Basic Portal
c. Authenticated Users Role: No
On the Ribbon, click the Save button.
Click on the Web Page Access Control navigation link.
On the Ribbon, click the Add Existing Web Page Access Control button.
When the “Look Up Records” dialog appears, click the New button.
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
On the Ribbon, Click the Save and Close button.
Click OK on the Look up Records dialog
On the Ribbon, click the Add Existing Web Page Access Control button.
When the “Look Up Records” dialog appears, click the New button.
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
On the Ribbon, Click the Save and Close button
22.
23.
24.
25.
26.
Click OK
Navigate to Contacts
Click to Add an existing contact to this web role
In the lookup Dialog, click New
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
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:
<add name="Xrm" connectionString="ServiceUri=https://userdemo.crm.dynamics.com;
[email protected]; Password=*********;"/>
6. Open IE and browse to the website
7. Open the web.config again
8. Modify the <portals> node under <Microsoft.xrm.portal> (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.
12.
13.
14.
15.
16.
17.
Navigate to the CRM
Click the Portals area of the SiteMap (left-hand navigation).
Click Websites.
Click Community Portal to open the Community Portal website record.
Click Forums on the left-hand nav bar
Click to Add a New Forum
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.
2.
3.
4.
5.
6.
7.
Navigate to the CRM
Click the Portals area of the SiteMap (left-hand navigation).
Click Websites.
Click Community Portal to open the Community Portal website record.
Click Idea Forums on the left-hand navigation area
Click to Add a New Idea Forum
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Navigate to the Community Portal website
Sign in as Administrator if you are not already signed in.
Click on Ideas on the primary navigation bar
Open the Example Idea Forum we create in the previous exercise
Navigate to the Suggest a New Idea part of the page
In the Idea textbox, type “Example Idea”
For the Description, type “Lorem Ipsum”
Click Submit Idea
Note that your Idea appears
You may up-vote your Idea by clicking on the Up-pointing arrow button to the left of the idea.
You may assign a score to the idea. Try clicking +3
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.
15.
16.
17.
18.
19.
20.
Navigate to the CRM
Click the Portals area of the SiteMap (left-hand navigation).
Click Websites.
Click Community Portal to open the Community Portal website record.
Click Blogs on the left-hand navigation area
Click to Add a New Blog
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.
2.
3.
4.
5.
6.
7.
8.
Navigate to the Community Portal website
Sign in as Administrator if you are not already signed in.
Click on Blogs on the primary navigation bar
Open the Blog we create in the previous exercise (My Own Little Blog) by clicking on the link on
the right-hand sidebar
Click New > Blog Post on the toolbox in the upper-right hand corner of the browser
Name the Blog Post “This is my First Post” and enter in something funny or interesting in the
Copy section.
Give the Blog Post a partial URL of first-post and Click Save
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.
Chapter 7: Portal Theming
Exercise 1: Edit the Copy of a Page Using Bootstrap
Elements
1.
2.
3.
4.
5.
Navigate to the Basic Portal Website
Login as Administrator if you are not already logged in.
Navigate to Content > Content Page
Edit the Copy using front-side editing
The tinyMCE editor will appear
Let’s play with a new simple styles that we can attach to elements:
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
Beneath the current content block, type a sentence “This is a sentence”
Follow this with a few paragraph breaks by hitting enter on your keyboard several times
Highlight the sentence and from the Styles dropdown select “Alert Info”
Save
Notice that the sentence you added is surrounded by an alert box
Click to edit the content block again.
Place your text cursor beneath the alert block you added
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)
Choose 3 rows and 3 columns
Place some dummy content spread throughout the table
Save
Notice how the table looks
Click to edit the content block again.
Select the table
Click to Insert and Attribute by clicking the button just left of the Format Dropdown
Click the Class dropdown and select table (begin typing the word to have the dropdown find it
for you)
Save
Notice how the table looks
Click to edit the content block again.
Now Edit the Markup by clicking the html button
Find the <table> node. It should have an attribute class=“table”. Change this to class=“table
table-striped”
Save
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.
30.
31.
32.
33.
34.
35.
36.
Click to edit the content block again.
Split the original Lorem Ipsum content block into two paragraphs
Now Edit the Markup by clicking the html button
Notice the original main content block is split into two <p> tags: one for each of the two
paragraphs you just split it into.
Wrap both of these <p> tags within a <div> tag that has class=“row”
Now wrap the first <p> tag within a <div> tag that has class=“span3”
Now wrap the second <p> tag within a <div> tag that has class=“span5”
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Navigate to http://bootswatchr.com/ OR http://www.bootstrapthemeroller.com/
Click to start Creating/ Rolling your theme
BE CREATIVE
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
Navigate to the Basic Portal Website
Sign in as administrator
On the home page, click to create a New child file by clicking New > child file on the front-side
editing toolbar.
Choose the bootstrap.min.css file you create by rolling your theme as the file upload.
For the name and partial URL both, enter bootstrap.min.css
Click Save
Refresh your cache by resetting the site in IIS, or rebuilding the project in VS 2012.
Your theme should be applied to the portal!
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Open Internet Explorer and navigate to your CRM online trial org
Navigate to the Settings Area of the Site Map
Click Customizations
Click Customize the System
Select Lead from the list of entities on the left navigation of the solution editor window.
Click Forms
Open the form titled Web Form
Click to Save As…
Name the form New Contact Us Form
Remove the following fields from the form: Street 1, City, State/Province, ZIP/Postal Code,
Country/Region, Description
11. Save and Close the form again.
12. Reorder the forms so that the new form you create is not the default form:
a. Click Form Order
b. Click Main Form Set
c. Move the newly created form to the bottom of the list
d. Click OK
13. Click Publish All Customizations – if this option isn’t shown, click to “information on the lefthand 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
2. Open the Basic Portal website.
3. Create a new Page Template for your form:
a. Click Page Templates
b. Click New
c. Specify the Name as Managed Forms Contact Us
d. Website: Basic Portal
e. Specify the Rewrite URL as ~/Pages/CrmEntityFormViewContactUs.aspx (we will
create this in the web project later)
f. Click Save & Close
4. Create a new Web Page using this template:
a. Click Web Pages
b. Click New
c. Specify the Name as Managed Forms Contact Us
d. Select the appropriate Website
e. Select the Home page as the Parent Page
f. Specify managed-forms-contact-us as the partial URL
g. Select the Managed Forms Contact Us Page Template created earlier
h. Select Published as the publishing state
i. Click Save & Close
5. Navigate to Web Link Sets
6. Click Primary Navigation
7. Click Web Links
8. Click New
9. Give the web link the follow values:
a. Name: Managed Contact Us
b. Page: Managed Forms Contact Us
c. Publishing State: Published
10. Save & Close
In Visual Studio
11. Open Visual Studio 2012.
12. Select File, Open Project.
13. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
14. Select AdxstudioPortals.sln then click the Open button.
15. In the Solution Explorer, expand the project: MasterPortal.
16. Create a new ASP.NET Web Form using Master Page in the ~/pages folder
17. Use the WebForms.master page
18. Save the file as “CrmEntityFormViewContactUs.aspx” in Pages folder contained in the root of
the project.
19. Replace the markup of the page with the following:
<asp:Content ContentPlaceHolderID="Head" runat="server">
<link rel="stylesheet" href="~/css/webforms.css" />
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" ViewStateMode="Enabled"
runat="server">
<asp:Panel ID="ContactForm" CssClass="crmEntityFormView frame" runat="server"
Visible="true">
<adx:CrmEntityDataSource ID="WebFormDataSource" runat="server" />
<adx:CrmEntityFormView runat="server" ID="FormView"
EntityName="lead" FormName="New Contact Us Form" DataSourceID="WebFormDataSource"
OnItemInserted="OnItemInserted">
</adx:CrmEntityFormView>
</asp:Panel>
<asp:Panel ID="ConfirmationMessage" runat="server" Visible="false">
<crm:Snippet runat="server" SnippetName="ContactUs/ConfirmationMsg"
DefaultText="Thank you. Your message has been successfully submitted."
EditType="html" />
</asp:Panel>
</asp:Content>
20. 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;
21. 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;
}
22. Build the project.
Let’s try out the form in the portal:
23. Navigate to the Basic Portal.
24. Navigate to the Managed Form Contact Us page on the portal. You should now see a form
resembling the one you created in CRM.
25. Fill in the form
a. First name: John
b. Last Name: Doe
c. Remaining values can be whatever you wish
CRM:
1. View the Submitted Leads in the CRM
a. Navigate to Sales
b. Click Leads
c. Find the John Doe record and open it
d. 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
4. Open the Basic Portal website.
5. Create a new Web Page:
a. Click Web Pages
b. Click New
c. Specify the Name as Entity Form Contact Us
d. Select the appropriate Website
e. Select the Home page as the Parent Page
f. Specify entity-form-contact-us as the partial URL
g. Select the Full Page Page Template
h. Select Published as the publishing state
i. Select Entity Form Contact Us as the Entity Form
j. Click Save & Close
6. Navigate to Web Link Sets
7. Click Primary Navigation
8. Click Web Links
9. Click New
10. Give the web link the follow values:
a. Name: Entity Form Contact Us
b. Page: Entity Form Contact Us
c. Publishing State: Published
11. Save & Close
Let’s try out the form in the portal:
12. Rebuild your VS 2012 project
13. Navigate to the Basic Portal.
14. 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:
i. Name: Contact Us Web Form
ii. Partial Url : contact-us-web-form
iii. Publishing State: published
iv. Page Template: Full Page
v. Website: Basic Portal
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
15. Navigate to Web Link Sets
16. Click Primary Navigation
17. Click Web Links
18. Click New
19. Give the web link the follow values:
a. Name: Contact Us Web Form
b. Page: Contact Us Web Form
c. Publishing State: Published
20. Save & Close
Let’s try out the form in the portal:
21. Rebuild your VS 2012 project
22. Navigate to the Basic Portal.
23. 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.
2.
3.
4.
5.
6.
Login to CRM
Navigate to Settings
Click Customizations
Click Customize the System
Click New > Entity
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
i. Click New
ii. Set the Name to “Description”
iii. Logical name: new_description
iv. Requirement Level: Required
v. Choose Multiple Lines of Text for the Type
vi. Save & Close
b. Add a Text Area Question
i. Click New
ii. The Name for the question: “How Heard”
iii. Logical name: new_howheard
iv. Choose Single Line of Text for the Type
v. Save & Close
c. Add a True/False Question
i. Click New
ii. The Name for the question: “Gold Star”
iii. Logical name: new_goldstar
10.
11.
12.
13.
14.
iv. Choose Two Options as the Type
v. Save & Close
d. Add a Multiple Choice Question
i. Add a series of fields, each one representing an answer to the question you have
planned (“How may we contact you?”)
ii. Click New
iii. Name: “Email”
iv. Logical name: new_mc1_email
v. Choose Two Options as the Type
vi. Save & Close
vii. Click New
viii. Name: “Phone”
ix. Logical name: new_mc1_phone
x. Choose Two Options as the Type
xi. Save & Close
xii. Click New
xiii. Name: “Fax”
xiv. Logical name: new_mc1_fax
xv. Choose Two Options as the Type
xvi. Save & Close
e. Add a Likert Scale Question
i. Click New
ii. The Name for the question: “Quality Rating”
iii. Logical Name: new_qualityrating
iv. Select the Option Set Type
v. Choose Use an Existing Option Set
vi. Choose Likert Scale Quality
vii. Save & Close
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
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
Click to create a new “main form”.
Click Save As and save it as Survey Step 2
Click Save As and save it as Survey Step 1
First we will edit the form for step 1 of the survey
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
Click on the Name field on the form, and then click Properties
Uncheck “Visible by default”
Check “Field is Read-only”
Close Properties window
Click on the Owner field on the form, then click Properties
Uncheck “Visible by default”
Check “Field is Read-only”
Close properties window
Click on the Notes tab on the form
Click Remove
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.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
Click to open the Survey Step 2 form
Click on the Name field on the form and click Properties
Uncheck “Visible by default”
Check “Field is Read-only”
Click on the Owner field on the form, the click Properties
Uncheck “Visible by default”
Check “Field is Read-only”
Click on the Notes tab on the form
Click Remove
Drag and drop the Quality Rating field onto the form
Click on it and click properties
Set the label to “Please Rate the quality of service you received from us”
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:
i. Drag and drop the ‘Email’ field onto the form
ii. Double-click on it or select it and click properties
iii. Click Formatting
iv. Select Check Box as the Control Formatting
v. Click OK
vi. Drag and drop the ‘Fax’ field onto the form
vii. Double-click on it or select it and click properties
viii. Click Formatting
ix. Select Check Box as the Control Formatting
x. Click OK
xi. Drag and drop the Phone field onto the form
xii. Double-click on it or select it and click properties
xiii. Click Formatting
xiv. Select Check Box as the Control Formatting
xv. Click OK
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:
i. Drag and drop the ‘Email’ field onto the form
ii. Double-click on it or select it and click properties
iii. Click Formatting
iv. Select Check Box as the Control Formatting
v. Click OK
vi. Drag and drop the ‘Fax’ field onto the form
vii. Double-click on it or select it and click properties
viii. Click Formatting
ix. Select Check Box as the Control Formatting
x. Click OK
xi. Drag and drop the Phone field onto the form
xii. Double-click on it or select it and click properties
xiii. Click Formatting
xiv. Select Check Box as the Control Formatting
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.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
Specify a Name for the Web Form: “Customer Support Survey”
Set Multiple Records Per User Permitted to “false”
Set Authentication Required to “true”
Click Save (but do not close the form – we aren’t done yet!)
Click Start Step lookup button
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)
Click Save
Click Next Step lookup button
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)
Click Metadata from the Survey Step 2 left navigation
Click Add New Web Form Metadata
Specify the Attribute Logical Name to be the logical name of the Likert scale question you
created: new_qualityrating
Select Option Set as Horizontal Radio Button List from the style dropdown, Control Style
section
Click Save & Close or OK all windows that remain open
Portal
71.
72.
73.
74.
Rebuild your web project or reset the website in IIS to reset the cache
Navigate to the portal
Sign in as administrator
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.
2.
3.
4.
Navigate to Workplace
Navigate to Customer Support Surveys
Locate the survey submission you just created and open it
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?
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
Open Internet Explorer and navigate to your CRM online trial org
Navigate to the Settings Area of the Site Map
Click Customizations
Click Customize the System
Select Lead from the list of entities on the left navigation of the solution editor window.
Click Views
Open the view titled Open Leads
Click to Save As…
Name the form New Open Leads View
Click the Name Column and click Change Properties
Change the width to 200px and click save
Remove the Created On column from the form
Click Add Columns
Check Email and click OK
Set the width of the Email Column to 200px
Save and Close the view again.
Click Publish All Customizations – if this option isn’t shown, click to “information on the lefthand side of the main solution window
Navigate to Portals
Open up the Basic Portal Website record
Create a new Web Page:
a. Click Web Pages
b. Click New
c. Specify the Name as Open Leads List
d. Select the appropriate Website
e. Select the Home page as the Parent Page
f. Specify open-leads-list as the partial URL
g. Select the Full Page Page Template
h. Select Published as the publishing state
i. Click Save
Open the Entity List lookup window
Click New
23. Now we are creating a new Entity View record to surface on the page
24. Fill in the following attributes:
a. Name: Open Leads List
b. Entity Name: Lead (lead)
c. View: New Open Leads View
d. Page Size: 10
25. Click Save & Close
26. Click OK
27. Click Save & Close
28. Navigate to Web Link Sets
29. Click Primary Navigation
30. Click Web Links
31. Click New
32. Give the web link the follow values:
a. Name: Open Leads List
b. Page: Open Leads List
c. Publishing State: Published
33. Save & Close
Let’s try out the form in the portal:
1. Rebuild your VS 2012 project
2. Navigate to the Basic Portal.
3. 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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
In the CRM, navigate to Portals
Click Entity Lists
Open up the Open Leads List Entity List you created in the previous exercise
Click the Web Page for Details View lookup Window
Click New
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
Click Save
Now Open the Entity Form Lookup Window.
Click New
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
Save & Close or click OK on all open windows
Let’s try out the form in the portal:
12. Rebuild your VS 2012 project
13. Navigate to the Basic Portal.
14. 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.
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.
2.
3.
4.
5.
6.
7.
8.
9.
In CRM, Navigate to Portals > Basic Portal
Navigate to Page Templates
Click Add New Page Template
Enter Events as the name
Add “~/Areas/Events/Pages/Events.aspx” as the Rewrite URL
Click Save & Close
Navigate to Web Pages
Click Add New Web Page
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.
2.
3.
4.
Navigate to Events
Click Add New Event
Adxstudio Portals
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.
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.
Chapter 12: Service Requests
Exercise 1: Create a new Service Request on the Portal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
Navigate to the Government Portal through the demo builder
Log in as administrator if you are not already logged in
Navigate to 311
Click to open a Pothole service request
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)
Click submit. Take Note of the Service Request Number
Navigate again to 311
Click View Map
Notice that your service request is located on the map
In the upper right hand corner, you will see your logged-in username (System Administrator)
Click on the down-pointing arrow next to your logged-in username to view the profile navigation
web link set
Click My Service Requests
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.
2.
3.
4.
5.
In CRM, navigate to Settings
Navigate to Customize the System
Click Entities
Click New to create a new entity
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
i. Click New
ii. Set the Display Name to “Closed Date”
iii. Logical name: new_closeddate
iv. Type: Date and Time
v. Format: Date and Time
vi. Save & Close
b. Add the “Email Address” field
i. Click New
ii. Set the Display Name to “Email Address”
iii. Logical name: new_emailaddress
iv. Type: Single Line of Text
v. Format: Email
vi. Save & Close
c. Add the “First Name” field
i. Click New
ii. Set the Display Name to “First Name”
d.
e.
f.
g.
h.
iii. Logical name: new_firstname
iv. Type: Single Line of Text
v. Format: Text
vi. Save & Close
Add the “Last Name” field
i. Click New
ii. Set the Display Name to “Last Name”
iii. Logical name: new_lastname
iv. Type: Single Line of Text
v. Format: Text
vi. Save & Close
Add the “Latitude” field
i. Click New
ii. Set the Display Name to “Latitude”
iii. Logical name: new_latitude
iv. Type: Decimal Number
v. Precision: 5
vi. Minimum Value: -90
vii. Maximum Value: 90
viii. Save & Close
Add the “Longitude” field
i. Click New
ii. Set the Display Name to “Longitude”
iii. Logical name: new_longitude
iv. Type: Decimal Number
v. Precision: 5
vi. Minimum Value: -180
vii. Maximum Value: 180
viii. Save & Close
Add the “Location” field
i. Click New
ii. Set the Display Name to “Location”
iii. Logical name: new_location
iv. Type: Single Line of Text
v. Format: Text
vi. Save & Close
Add the “Phone Number” field
i. Click New
ii. Set the Display Name to “Phone Number”
iii. Logical name: new_phonenumber
iv. Type: Single Line of Text
v. Format: Text
vi. Save & Close
Add the “Priority” field
i. Click New
ii. Set the Display Name to “Priority”
iii. Logical name: new_priority
iv. Type: Option Set
v. Choose Use Existing Option Set
vi. Option Set: Service Request Priority
vii. Save & Close
j. Add the “Regarding Contact” field
i. Click New
ii. Set the Display Name to “Regarding Contact”
iii. Logical name: new_regardingcontact
iv. Type: Lookup
v. Target Record Type: Contact
vi. Relationship Name: new_specialrequest_regardingcontact
vii. Save & Close
k. Add the “Regarding Lead” field
i. Click New
ii. Set the Display Name to “Regarding Lead”
iii. Logical name: new_regardinglead
iv. Type: Lookup
v. Target Record Type: Lead
vi. Relationship Name: new_specialrequest_regardinglead
vii. Save & Close
l. Add the “Scheduled Date” field
i. Click New
ii. Set the Display Name to “Scheduled Date”
iii. Logical name: new_scheduleddate
iv. Type: Date and Time
v. Format: Date and Time
vi. Save & Close
m. Add the “Incident Date” field
i. Click New
ii. Set the Display Name to “Incident Date”
iii. Logical name: new_incidentdate
iv. Type: Date and Time
v. Format: Date and Time
vi. Save & Close
n. Add the “Service Request” field
i. Click New
ii. Set the Display Name to “Service Request”
iii. Logical name: new_servicerequest
iv. Type: Lookup
i.
v. Target Record Type: Service Request
vi. Relationship Name: new_specialrequest_servicerequest
vii. Save & Close
o. Add the “Service Request Number” field
i. Click New
ii. Set the Display Name to “Service Request Number”
iii. Logical name: new_servicerequestnumber
iv. Type: Single Line of Text
v. Format: Text
vi. Save & Close
p. Add the “Service Status” field
i. Click New
ii. Set the Display Name to “Service Status”
iii. Logical name: new_servicestatus
iv. Type: Option Set
v. Choose Use Existing Option Set
vi. Option Set: Service Status
vii. Save & Close
q. Add a (custom) Description field
i. Click New
ii. Set the Display Name to “Description”
iii. Logical name: new_description
iv. Type: Multiple Lines of Text
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”
i. Select the “General” tab
ii. Click the Insert tab
iii. Click Two Columns
iv. Click on the new section to select it
v. On the home tab, click Change Properties
vi. Set the label to “Contact Details”
12.
13.
14.
15.
16.
17.
vii. Click “Show the label of this section on the form
viii. Click “Show a line at the top of the section”
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
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”
Click Save
Now Click Save As and Name it Web Form – we will not customize it to suit what is needed
on the portal
Remove the Notes Tab form the Form
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
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
In the main CRM navigation console, click Settings
Under the “portals” subsection, navigate to “Service Request Types”
Click New
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
Click the Web Form lookup Window
Click New
Enter “Special Request Web Form”
Set “Start New Session On Load” to true
Click Save
Click the Start Step Lookup window
Click New
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
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.
2.
3.
4.
5.
6.
7.
Download the latest Microsoft CRM SDK and install
Under your CRM SDK install folder, navigate to sdk > tools > pluginregistration
Open pluginregistrationtool.sln in VS 2012
Rebuild all
Navigate to the bin > Debug folder and run PluginRegistration.exe
Use the following connection information to navigate to your CRM org:
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
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
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/
Enter your credentials and click Next
Double-Click on your CRM Organization on the left-hand side navigation
Locate the Adxstudio.Xrm.Plugins.Service311 plugin assembly
Expand this assembly and select the
Adxstudio.Xrm.Plugins.Service311.CustomServiceRequestGeoAsyncPlugin
Select Register > Register New Step
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”
Select Register > Register New Step
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”
Select the Adxstudio.Xrm.Plugins.Service311.NewCustomServiceRequestPlugin
Select Register > Register New Step
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
Select the Adxstudio.Xrm.Plugins.Service311.UpdateCustomServiceRequestPlugin
Select Register > Register New Step
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.
Chapter 14: Portal Structure
Exercise 1: Add forums to Basic Portal
In this exercise, we will add forums to basic portal.
1.
2.
3.
4.
5.
6.
7.
8.
9.
In CRM, navigate to Portals
Open up the Basic Portal
Navigate to Page Templates
Click Add New Page Template
Give the Page Template the following attributes:
a. Name: Forum
b. Website: Basic Portal
c. Rewrite Url: ~/Areas/Forums/Pages/Forum.aspx
Click Save & Close
Click Add New Page Template
Give the Page Template the following attributes:
a. Name: Forum Thread
b. Website: Basic Portal
c. Rewrite Url: ~/Areas/Forums/Pages/ForumThread.aspx
Click Save & Close
Portal:
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
Rebuild the MasterPortal project
Navigate to the Portal
Log in as administrator if you are not already logged in.
Navigate to the home page by clicking the house icon in the primary navigation
Locate the front-side editing panel on the upper-right hand corner
Click New > Child Page
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
Click Save
You will now be redirect to the Forums Page. Before you do anything with this page, add a Web
Link to the Primary Navigation
Click the Edit button that appears when you mouse over the primary navigation
Add a new Web Link by clicking the “+” icon
Attributes:
22.
23.
24.
25.
26.
a. Name: Forum
b. Page: Forums
c. Publishing State: Published
Click Save
On the “Forums” page, click New > Child Forum
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
Click Save
You may now use the forum. Try creating a new thread.
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Open Visual Studio 2012.
Select File, Open Project.
Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
Select AdxstudioPortals.sln then click the Open button.
In the Solution Explorer, expand the project: MasterPortal
Navigate to the pages folder
Right-click on the pages Folder and select Add > New Item
Choose Web Form using Master Page
Name it Example.aspx
Choose WebFormsContent.master as the master page.
Inside the “MainContent” <asp:Content> tag; Copy and paste the following markup:
<crm:CrmEntityDataSource ID="CurrentEntity" DataItem="<%$ CrmSiteMap: Current %>"
runat="server" />
<crm:Property DataSourceID="CurrentEntity" PropertyName="Adx_Copy" EditType="html"
runat="server" />
CRM
1.
2.
3.
4.
5.
Navigate to Portals > Websites
Open the Basic Portal website entity in the CRM
Click Page Templates in the left-hand Side navigation
On the ribbon, click to Add a New Page Template
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
8. On the ribbon, click the Add New Web Page button.
9. Complete the following fields:
a. Name: Example Page
b. Website: Basic Portal
c. Parent Page: Home
d. Partial Url: example
e. Page Template: Example Template
f. Publishing State: Published
g. Copy: This is my example page
h. Set the value of the Summary field to: This is the Summary
10. On the Ribbon, click the Save and Close button to save your changes
11. Select Web Link Sets
12. Open Primary Navigation
13. Click once on the Links grid on the form
14. Click the Add New Web Link button on the ribbon
a. Name: Example
b. Page: Example Page
c. Publishing State: Published
d. Click Save & Close
15. Now rebuild the project in VS2012
16. 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
17. Navigate to the Pages folder.
18. Open Example.aspx you created earlier.
19. Copy the following markup:
<crm:Property ID="Summary" DataSourceID="CurrentEntity"
PropertyName="Adx_Summary" EditType="text"
runat="server" />
20. And paste it beneath the <crm:CrmEntityDataSource> control already on the page
21. Note that the only thing different between this control and the other <crm:Property> control on
this page is that the data is being drawn from the summary attribute of the web page rather than
the adx_copy.
22. Save and rebuild.
23. Navigate to your portal
24. When the Example page loads, you should now see the title you added in Step 2 displayed just
above the Example page copy.
25. Note the Datasource that both property controls on the page are data-binding to:
<crm:CrmEntityDataSource ID="CurrentEntity" DataItem="<%$ CrmSiteMap: Current %>"
runat="server" />
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.
4. 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)
5. Complete the following fields:
a. Name: My News
b. Web Site: Basic Portal
c. Page: News
6. On the Ribbon, click the Save and Close button.
7. Click on the Content Snippets navigation item.
8. On the Ribbon, click the Add New Content Snippet button. This will specify the label on the
Hyperlink.
9. Complete the following fields:
a. Name: My News Link Title
b. Website: Basic Portal
c. Type: Text
d. Value: News
10. On the Ribbon, click the Save and Close button.
Visual Studio
11. Open Example.aspx.
12. Add the following markup on the line just below the Adx_Copy <property> control:
<crm:CrmHyperLink
ID="NewsLink"
SiteMarkerName="My News"
Text="<%$ Snippet: My News Link Title, News %>"
runat="server">
</crm:CrmHyperLink>
13. Save your changes and rebuild the project.
14. Navigate to your basic portal, then navigate to the Example Page
15. When the Example page loads, you should now see a News hyperlink just below the home page
copy.
16. 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:
<crm:Snippet SnippetName="MySnippet" Editable="True/False" EditType="html"
runat="server"/>
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Under Basic Portal, Click on the Web Link Sets navigation item.
On the Ribbon, click the Add New Web Link Set button.
In the Name field, enter: Blogs We Follow.
On the Ribbon, click the Save button.
Click the Web Links navigation item.
On the Ribbon, click the Add New Web Link button.
Complete the following fields:
a. Name: Mitch’s Blog
b. Web Link Set: Blogs We Follow
c. Website: Basic Portal
d. External Url: http://blogs.infinite-x.net
e. Publishing State: Published
f. Display Order: 1
g. Open in New Window: Yes
h. Leave the remainder of the fields at their default values.
On the Ribbon, click the Save and Close button.
On the Ribbon, click the Add New Web Link button.
Complete the following fields:
a. Name: Basic Portal Homepage
b. Web Link Set: Blogs We Follow
c. Website: Basic Portal
d. Page: Home
e. Publishing State: Published
f. Display Order: 2
g. Open in New Window: No
h. Leave the remainder of the fields at their default values.
On the Ribbon, click the Save and Close button.
Visual Studio
12. Navigate to the Pages folder.
13. Open Example.aspx.
14. Copy and paste the following into the SidebarContent <asp:Content> tag:
<crm:WebLinks WebLinkSetName="Blogs We Follow" CssClass="navigation" runat="server" />
15. Save and rebuild the project. Navigate to the Portal.
16. 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.
2. Open Example.aspx
3. 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.
4. Add the following code within the “ContentBottom” <asp:Content> tag:
<crm:CrmSiteMapChildView runat=”server">
<LayoutTemplate>
<div class="navigation frame">
<ul>
<asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
</ul>
</div>
</LayoutTemplate>
<ItemTemplate>
<li>
<asp:HyperLink
NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>'
runat="server" />
<crm:CrmEntityDataSource
ID="ChildEntity"
DataItem='<%# Container.DataItem %>'
runat=“server” />
<crm:Property
DataSourceID="ChildEntity"
PropertyName="Adx_Summary,Adx_Description"
EditType="html"
runat="server" />
</li>
</ItemTemplate>
</crm:CrmSiteMapChildView>
5. Rebuild the project. Navigate to the Portal
6. 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.
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
2. Open Example.aspx
3. Insert the following code within the “ContentBottom” <asp:Content> tag:
<crm:CrmMetadataDataSource
ID="SatisfactionSource"
runat="server"
AttributeName="customersatisfactioncode"
EntityName="incident"
SortExpression=“Label DESC” />
<asp:Label
AssociatedControlID="Satisfaction"
runat="server"
Text="Satisfaction" />
<asp:DropDownList
ID="Satisfaction"
runat="server"
DataSourceID=“SatisfactionSource"
DataTextField="OptionLabel"
DataValueField="OptionValue" />
4. Build the project. Navigate to the Portal
5. When the home page is displayed, you should see a drop-down list containing customer
satisfaction codes from the Case entity within CRM.
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Open Internet Explorer and navigate to your CRM online trial org
Navigate to the Settings Area of the Site Map
Click Customizations
Click Customize the System
Select Lead from the list of entities on the left navigation of the solution editor window.
Click Forms
Open the form titled Web Form
Click to Save As…
Name the form New Contact Us Form
Remove the following fields from the form: Street 1, City, State/Province, ZIP/Postal Code,
Country/Region, Description
11. Save and Close the form again.
12. Reorder the forms so that the new form you create is not the default form:
a. Click Form Order
b. Click Main Form Set
c. Move the newly form to the bottom of the list
d. Click OK
13. Click Publish All Customizations – if this option isn’t shown, click to “information on the lefthand 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
2. Open the Basic Portal website.
3. Create a new Page Template for your form:
a. Click Page Templates
b. Click New
c. Specify the Name as Managed Forms Contact Us
d. Website: Basic Portal
e. Specify the Rewrite URL as ~/Pages/CrmEntityFormViewContactUs.aspx (we will
create this in the web project later)
f. Click Save & Close
4. Create a new Web Page using this template:
a. Click Web Pages
b. Click New
c. Specify the Name as Managed Forms Contact Us
d. Select the appropriate Website
e. Select the Home page as the Parent Page
f. Specify managed-forms-contact-us as the partial URL
g. Select the Managed Forms Contact Us Page Template created earlier
h. Select Published as the publishing state
i. Click Save & Close
5. Navigate to Web Link Sets
6. Click Primary Navigation
7. Click Web Links
8. Click New
9. Give the web link the follow values:
a. Name: Managed Contact Us
b. Page: Managed Forms Contact Us
c. Publishing State: Published
10. Save & Close
In Visual Studio
11. Open Visual Studio 2012.
12. Select File, Open Project.
13. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
14. Select AdxstudioPortals.sln then click the Open button.
15. In the Solution Explorer, expand the project: MasterPortal.
16. Create a new ASP.NET Web Form using Master Page in the ~/pages folder
17. Use the WebForms.master page
18. Save the file as “CrmEntityFormViewContactUs.aspx” in Pages folder contained in the root of
the project.
19. Replace the markup of the page with the following:
<asp:Content ContentPlaceHolderID="Head" runat="server">
<link rel="stylesheet" href="~/css/webforms.css" />
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" ViewStateMode="Enabled"
runat="server">
<asp:Panel ID="ContactForm" CssClass="crmEntityFormView frame" runat="server"
Visible="true">
<adx:CrmDataSource ID="WebFormDataSource" runat="server" />
<adx:CrmEntityFormView runat="server" ID="FormView"
EntityName="lead" FormName="New Contact Us Form" DataSourceID="WebFormDataSource"
OnItemInserted="OnItemInserted">
</adx:CrmEntityFormView>
</asp:Panel>
<asp:Panel ID="ConfirmationMessage" runat="server" Visible="false">
<crm:Snippet runat="server" SnippetName="ContactUs/ConfirmationMsg"
DefaultText="Thank you. Your message has been successfully submitted."
EditType="html" />
</asp:Panel>
</asp:Content>
20. 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;
21. 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;
}
22. Build the project.
Let’s try out the form in the portal:
23. Navigate to the Basic Portal.
24. Navigate to the Managed Form Contact Us page on the portal. You should now see a form
resembling the one you created in CRM.
25. Fill in the form
a. First name: John
b. Last Name: Doe
c. Remaining values can be whatever you wish
CRM:
26. View the Submitted Leads in the CRM
a. Navigate to Sales
b. Click Leads
c. Find the John Doe record and open it
d. Note the lead created matches the data previously entered though the portal.
Chapter 17: Managed Lists
Exercise 1: Add a CrmDataSource Control
Visual Studio
1. Open the Basic Portal Project
2. Open Example.aspx
3. We will use fetchXml to establish our data source: a CRM query. We will then databind our
gridview to the results of this query
4. Enter the following within the “ContentBottom” <asp:Content> tag:
<adx:CrmDataSource ID="AccountDataSource" runat="server">
<FetchXml>
<fetch version="1.0"
output-format="xml-platform" mapping="logical" distinct="false">
<entity name="account">
<attribute name="name" />
<attribute name="address1_city" />
<attribute name="telephone1" />
<filter type=“and”>
<condition attribute="statecode" operator="eq" value="0" />
</filter>
</entity>
</fetch>
</FetchXml>
</adx:CrmDataSource>
<asp:GridView runat="server"
DataSourceID="AccountDataSource" AutoGenerateColumns="False"
AllowSorting="True" AllowPaging="True" PageSize="5">
<Columns>
<asp:BoundField DataField='name' HeaderText="Name" SortExpression="name" />
<asp:BoundField DataField='address1_city' HeaderText="City" />
<asp:BoundField DataField='telephone1' HeaderText="Telephone" />
</Columns>
</asp:GridView>
5. Rebuild the project. Navigate to the Portal
6. 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.
2.
3.
4.
5.
6.
7.
8.
9.
Open Visual Studio 2012.
Select File, Open Project.
Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
Select AdxstudioPortals.sln then click the Open button.
In the Solution Explorer, expand the project: MasterPortal.
Create a new ASP.NET Web Form using Master Page in the ~/pages folder
Use the WebForms.master page
Name it LeadQueryView.aspx
Replace the markup of the page with the following:
<asp:Content ContentPlaceHolderID="MainContent" ViewStateMode="Enabled"
runat="server">
<asp:GridView ID="LeadList" CssClass="table table-bordered table-striped"
runat="server"></asp:GridView>
</asp:Content>
10. Change the class definition of the page so that it inherits from PortalPage:
public partial class LeadQueryView : PortalPage
11. 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;
12. 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();
13. Build the project.
In CRM:
14.
15.
16.
17.
18.
Navigate to Portals > Websites
Open the Basic Portal website entity in the CRM
Click Page Templates in the left-hand Side navigation
On the ribbon, click to Add a New Page Template
Complete the following Fields:
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
a. Name: Lead Query View
b. Website: Basic Portal
c. Rewrite URL: ~/Pages/LeadQueryView.aspx
Click Save
Click Web Pages in the left-hand side navigation
On the ribbon, click the Add New Web Page button.
Complete the following fields:
a. Name: Lead List
b. Website: Basic Portal
c. Parent Page: Home
d. Partial Url: lead-list
e. Page Template: Lead Query View
f. Publishing State: Published
On the Ribbon, click the Save and Close button to save your changes
Select Web Link Sets
Open Primary Navigation
Click once on the Links grid on the form
Click the Add New Web Link button on the ribbon
a. Name: Leads
b. Page: Lead List
c. Publishing State: Published
d. Display Order: 4
e. Click Save & Close
Now rebuild the project in VS2012
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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
Navigate to Portals >Websites > Basic Portal
Click Web Pages
Create a new Web Page containing the Entity Form for displaying a case:
Name:Lead Form
Parent Page: Lead List
Partial Url: view-lead
Page Template: Page
Publishing State: Published
Open The Entity Form lookup window
In the lookup window, click New
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
Click Save & Close
Click OK to set the Entity Form on the web page
Click Save
Click Site Markers
Click Add New Site Marker
Set the Name to “Lead Details”
Set the Website to Basic Portal
Ensure the Page is set to Lead Form
Save & Close
In VS 2012
30. Open Visual Studio 2012.
31. Select File, Open Project.
32. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
33. Select AdxstudioPortals.sln then click the Open button.
34. 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(@" <a href=""{0}"" >{1}</a>",
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:
<asp:GridView ID="LeadList" OnRowDataBound="LeadList_OnRowDataBound" CssClass="table
table-bordered table-striped" runat="server"></asp:GridView>
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!
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
b. Select File, Open Project
c. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
d. Select AdxstudioPortals.sln then click the Open button
e. In the Solution Explorer, expand the project: MasterPortal
i. Create a new ASP.NET Web Form using Master Page in the ~/pages folder
f. Use the WebForms.master page
g. Name it Example.aspx
2. Inside the “MainContent” <asp:Content> tag; copy and paste the following markup:
<asp:Label ID="FirstLeadLabel" runat="server"></asp:Label>
3. Change the class definition of the page so that it inherits from PortalPage:
public partial class Example : PortalPage
4. Add the following Code to the Page_Load method:
var leads = XrmContext.LeadSet;
var firstLead = leads.FirstOrDefault();
FirstLeadLabel.Text = firstLead.FullName;
5. Save all.
In CRM:
6. 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:
i. Name: Example Template
ii. Website: Basic Portal
iii. Rewrite URL: ~/Pages/Example.aspx
f. Click Save
g. Click Web Pages in the left-hand side navigation
h. On the ribbon, click the Add New Web Page button.
i. Complete the following fields:
i. Name: Example Page
ii. Website: Basic Portal
iii. Parent Page: Home
iv. Partial Url: example
v. Page Template: Example Template
vi. Publishing State: Published
vii. Copy: This is my example page
viii. Set the value of the Summary field to: This is the Summary
j. On the Ribbon, click the Save and Close button to save your changes
k. Select Web Link Sets
l. Open Primary Navigation
m. Click once on the Links grid on the form
n. Click the Add New Web Link button on the ribbon
i. Name: Example
ii. Page: Example Page
iii. Publishing State: Published
iv. Display Order: 3
v. Click Save & Close
7. Now rebuild the project in VS2012
8. 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
2. Add the following Code to the Page_Load method:
var dynamicLeads = ServiceContext.CreateQuery("lead");
var firstDynamicLead = dynamicLeads.FirstOrDefault();
FirstLeadLabel.Text = firstDynamicLead.GetAttributeValue<string>("fullname");
3. Save all.
4. 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.
2.
3.
4.
Navigate to Portals > Websites > Basic Portal
Click on the Web Pages navigation link on the left-hand side
Open Example Page that you created earlier
Change the Comment Policy to Open.
Visual Studio
5.
6.
7.
8.
9.
10.
11.
12.
Open Visual Studio 2012.
Select File, Open Project.
Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
Select AdxstudioPortals.sln then click the Open button.
In the Solution Explorer, expand the project: MasterPortal.
Navigate to the Pages folder.
Open Example.aspx you created earlier.
Add the following declaration:
<%@ Register src="~/Controls/Comments.ascx" tagname="Comments" tagprefix="adx" %>
13. In the location where you would like your page rating control displayed, add the following:
<adx:Comments RatingType="vote" EnableRatings="true" runat="server" />
14. Rebuild the project and test the portal.
Exercise 4: Add a Rating Control
CRM
15.
16.
17.
18.
Navigate to Portals > Websites > Basic Portal
Click on the Web Pages navigation link on the left-hand side
Open Example Page that you created earlier
Change the Comment Policy to Open.
Visual Studio
19.
20.
21.
22.
23.
24.
25.
26.
Open Visual Studio 2012.
Select File, Open Project.
Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
Select AdxstudioPortals.sln then click the Open button.
In the Solution Explorer, expand the project: MasterPortal.
Navigate to the Pages folder.
Open Example.aspx you created earlier.
Open your page template and add the following declaration:
<%@ Register src="~/Controls/MultiRatingControl.ascx" tagname="MultiRatingControl"
tagprefix="adx" %>
27. In the location where you would like your page rating control displayed, add the following:
<adx:MultiRatingControl ID="MultiRatingControl" RatingType="rating" runat="server" />
28. Rebuild the project and test the portal.
Chapter 19: Ads and Polls
Exercise 1: Add an Advertisement to the Basic Portal
CRM
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Navigate to the Basic Portal Website Entity
Click the Ad Placement navigation link.
On the Ribbon, click the Add New Ad Placement button.
Enter the following properties:
a. Name: Fine Books
On the Ribbon, click the Save button.
Click the Ads navigation link.
On the Ribbon, click the Add Existing Ad button.
When the Lookup dialog is displayed, click the New button.
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
On the Ribbon, click the Save and Close button.
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:
<adx:AdPlacement ID="MainAd" PlacementName="Fine Books" runat="server">
</adx:AdPlacement>
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.
2. On the Ribbon, click the Add New Poll Placement button.
3. Enter the following properties:
a. Name: Installation Timeframe
b. The remaining fields are fine with their default values.
4. On the Ribbon, click the Save button.
5. Click the Polls navigation link.
6. On the Ribbon, click the Add Existing Poll button.
7. When the Lookup dialog is displayed, click the New button.
8. Complete the following fields:
a. Name: Installation Timeframe
b. Question: When will you be installing Dynamics CRM 2011?
c. Submit button label: Vote
9. On the Ribbon, click the Save button.
10. Click the Options navigation link.
11. On the Ribbon, click the Add New Poll Options button.
12. Complete the following properties:
a. Name: Immediately
b. Answer: Immediately
13. On the Ribbon, click the Save and New button.
14. Complete the following properties:
a. Name: 6 months
b. Answer: 6 months
15. On the Ribbon, click the Save and New button.
16. Complete the following properties:
a. Name: 1 year
b. Answer: 1 year
17. On the Ribbon, click the Save and Close button.
18. On the Ribbon, click the Save and Close button.
19. When you return to the Lookup dialog, click the Ok button.
Visual Studio
20. Open Example.aspx.
21. Insert the following control into the MainContent content control:
<adx:PollPlacement ID="Polls" PlacementName="Installation Timeframe" runat="server">
</adx:PollPlacement>
22. Save and Run the project.
23. When the Basic Portal home page is displayed, you should see an Installation Timeframe poll
located at the bottom of the content are
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:
a. Open Visual Studio 2012.
b. Select File, Open Project.
c. Navigate to: C:\Program Files\ADXSTUDIO\XrmPortals\6.X.XXXX\Samples.
d. Select AdxstudioPortals.sln then click the Open button.
e. In the Solution Explorer, expand the project: MasterPortal.
i. Create a new ASP.NET Web Form using Master Page in the ~/pages folder
f. Use the WebForms.master page
g. Name it Example.aspx
2. Change the class definition of the page so that it inherits from PortalPage:
public partial class Example : PortalPage
3. Add the following declaration to the top of the markup:
<%@ Import namespace="Adxstudio.Xrm.Web.Mvc.Html" %>
4. Add the following to the markup inside the MainContent content placeholder:
MVC Attribute Control:
<%= Html.Attribute("adx_copy") %>
5. Save all.
In CRM:
6. 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:
i. Name: Example Template
ii. Website: Basic Portal
iii. Rewrite URL: ~/Pages/Example.aspx
f. Click Save
g. Click Web Pages in the left-hand side navigation
h. On the ribbon, click the Add New Web Page button.
i. Complete the following fields:
87
i. Name: Example Page
ii. Website: Basic Portal
iii. Parent Page: Home
iv. Partial Url: example
v. Page Template: Example Template
vi. Publishing State: Published
vii. Copy: This is my example page
viii. Set the value of the Summary field to: This is the Summary
j. On the Ribbon, click the Save and Close button to save your changes
k. Select Web Link Sets
l. Open Primary Navigation
m. Click once on the Links grid on the form
n. Click the Add New Web Link button on the ribbon
i. Name: Example
ii. Page: Example Page
iii. Publishing State: Published
iv. Display Order: 3
v. Click Save & Close
7. Now rebuild the project in VS2012
8. Navigate to the Portal and navigate to the new example page you just created.
Experiment
1) Experiment with the different ways to use the Attribute Helpers:
<%=
<%=
<%=
<%=
Html.Attribute(Html.Website(), "adx_name") %>
Html.Attribute<Xrm.Adx_webpage>(p => p.Adx_name) %>
Html.TextAttribute("adx_title") %>
Html.HtmlAttribute("adx_summary") %>
<%= Html.AttributeLiteral("adx_copy") %>
88
Exercise 2: Use the Site Setting Helpers
IN CRM
1. Navigate to Portals > Websites > Basic Portal
2. Navigate to Site Settings
3. Create a new Site Setting:
a. Name: Example Boolean Setting
b. Value: true or false
c. Save & Close
In Vs 2012
4. Open Example.aspx
5. Add the following to the markup:
<% if (Html.BooleanSetting("Example Boolean Setting") ?? false) %>
<% { %>
<p> The Boolean Setting is set to true!</p>
<% } else { %>
<p> The Boolean Setting is set to false! </p>
<% } %>
6. Save all
7. Rebuild the project
8. 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.
89
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.
d. 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)
e. Complete the following fields:
i. Name: My News
ii. Web Site: Basic Portal
iii. Page: News
f. On the Ribbon, click the Save and Close button.
2. In VS 2012, Open Example.aspx
3. Add the following to the markup of the page, In the “Main Content” content area:
<%= Html.SiteMarkerLink("My News") %>
4. Save and rebuild the project then browse to see the results
90
Exercise 4: Use the Snippet Helpers
1. In the CRM, open Portals > Websites > Basic Portal
2. Navigate to Content Snippets
3. Create a new Content Snippet:
a. Name: Example Content Snippet
b. Value: This is a Snippet.
c. Save & Close
In VS 2012
4. Open Example.aspx
5. Add the following to the markup of the page, In the “Main Content” content area:
%= Html.TextSnippet("Example Content Snippet") %>
6. 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") %>
91
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.
b. On the Ribbon, click the Add New Web Link Set button.
c. In the Name field, enter: Blogs We Follow.
d. On the Ribbon, click the Save button.
e. Click the Web Links navigation item.
f. On the Ribbon, click the Add New Web Link button.
g. Complete the following fields:
i. Name: Mitch’s Blog
ii. Web Link Set: Blogs We Follow
iii. Website: Basic Portal
iv. External Url: http://blogs.infinite-x.net
v. Publishing State: Published
vi. Display Order: 1
vii. Open in New Window: Yes
viii. Leave the remainder of the fields at their default values.
h. On the Ribbon, click the Save and Close button.
i. On the Ribbon, click the Add New Web Link button.
j. Complete the following fields:
i. Name: Basic Portal Homepage
ii. Web Link Set: Blogs We Follow
iii. Website: Basic Portal
iv. Page: Home
v. Publishing State: Published
vi. Display Order: 2
vii. Open in New Window: No
viii. Leave the remainder of the fields at their default values.
k. On the Ribbon, click the Save and Close button.
In VS 2012
2. Open Example.aspx
3. Add the following Code to the MainContent content placeholder area:
92
<% foreach (var link in Html.WebLinkSet("Blogs We Follow").WebLinks) %>
<% { %>
<p><%= Html.WebLink(link) %></p>
<% } %>
4. 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 <adx:Weblinks> web control. Html.WebLinksDropdown, on the other hand,
gives more advancing rendering of bootstrap dropdowns for sub menus, etc. Play with the
different options.
93
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 fullyfeatured MVC app.
In CRM:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
94
Navigate to Marketing
Click Campaigns on the left-hand side navigation
Click to Create a New Campaign
Give the Campaign the following values:
a. Name: My Campaign
b. Description: This is the description of my Campaign
c. Leave the remainder of the fields at their default values
d. Click Save & Close
Navigate to Portals > Websites
Open Basic Portal
Navigate to Web Pages
Create a new Web Page with the following values:
a. Name: Campaign View Area
b. Website: Basic Portal
c. Parent Page: Home
d. Partial Url: campaign-view
e. Page Template: Page
f. Publishing State: Published
g. Save but do not close the form
Navigate to Web Links on the left-hand side navigation
Click Add New Web Link
Give the Web link the following values:
a. Name: Campaign View Area
b. Web Link Set: Primary Navigation
c. Page: Campaign View Area
d. Publishing State: Published
e. Save & Close
Navigate to Site Markers on the left-hand navigation
Click Add New Site Marker
Give the Site Marker the following values:
a. Name: Campaign View Area
b. Website: Basic Portal
c. Page: Campaign View Area
d. 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
15.
16.
17.
18.
Right-Click on the Areas folder in the MasterPortal web project
Select New > Area
Enter MyCampaigns as the Area Name
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.
19. Include the following Using Statement:
using Adxstudio.Xrm.Web.Mvc;
20. 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 }
);
21.
22.
23.
24.
25.
Right-click on the Models folder in your new Area
Select Add > New Item
Under Code, select Class
Name your class CampaignViewModel.cs
Add the following declarations to the top of the code file:
using Microsoft.Xrm.Sdk;
using Xrm;
26. Add the following property to the new view model class you have created:
public List<Campaign> Campaigns;
27.
28.
29.
30.
Right-click on the Controllers folder in your new Area
Select Add > Controller
Controller name: CampaignController
Add the following declarations to the top of the file:
using Adxstudio.Xrm.Web.Mvc;
using Site.Areas.MyCampaigns.Models;
using Xrm;
31. Replace the entire Index( ) ActionResult function with the following:
public ActionResult Index()
{
var context = new XrmServiceContext();
var campaigns = context.CampaignSet;
95
var viewModel = new CampaignViewModel()
{
Campaigns = campaigns.ToList()
};
return View(viewModel);
}
32.
33.
34.
35.
36.
37.
38.
Right-click on the Views > Shared folder in your Area
Select New > View
Set Index as the name of your view
Set your view Engine to ASPX (C#)
Choose “Use a layout or master page”
For the master page, choose “~/MasterPages/Default.master”
Replace the entire contents of the Index.aspx file with the following:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.master"
Inherits="System.Web.Mvc.ViewPage<Site.Areas.MyCampaigns.Models.CampaignViewModel>" %>
<%@ OutputCache CacheProfile="User" %>
<%@ Import Namespace="System.Web.Mvc.Html" %>
<%@ Import Namespace="Adxstudio.Xrm.Web.Mvc.Html" %>
<asp:Content runat="server" ContentPlaceHolderID="MainContent">
<%= Html.HtmlAttribute("adx_copy") %>
<ul class="unstyled">
<% foreach (var campaign in Model.Campaigns)
{ %>
<li>
<div class="bottom-break"><%= campaign.Description %></div>
</li>
<% } %>
</ul>
</asp:Content>
39. Save all and Rebuild the project.
40. Brows to your campaign View Area in Basic Portal.
96