Demystifying Dynamics 365 Portal Projects - Part 2 Profile Page
Photo by Emanuel Villalobos on Unsplash |
PART 1: DEMYSTIFYING DYNAMICS 365 PORTAL PROJECTS - PART 1 PLANNING & ANALYSIS
PART 3: DEMYSTIFYING DYNAMICS 365 PORTAL PROJECTS - PART 3 ENTITY FORMS, ENTITY LISTS
In the part
1 of the series, I shed light on some of planning and analysis activities
involved in a Portal project. From this part, I will be writing about some
common portal project requirements and the way I have addressed those
requirements.
Site Settings
One of the most
basic portal configurations happen in Site Settings. Site Settings contain some
global configuration used by portal framework. The complete list of portal site
settings can be found here.
However, there are some settings are deprecated since this link is taken from
ADXStudio product and there are some settings that you will not find in the
given link and I am listing down those settings in the below table:
Setting
|
Description
|
Search/Enabled
|
A
true or false value. If set to false will disable the search functionality
from the portal so you will not see the magnifier sign on the primary
navigation
|
DateTime/DateFormat
|
The
format you want to show dates in your portal. For example, for British
datetime format, I use d/M/yyyy
|
profile/forcesignup
|
A
true or false value. If set to true will force user to update their profile
after signup. It means portal will redirect the user to the Profile page
after successful signup
|
Authentication/Registration/TermsAgreementEnabled
|
A
true or false value. If set to true, the portal will display the terms and
conditions of the site. Users must agree to the terms and conditions before
they are considered authenticated and can use the site.
|
Authentication/Registration/ProfileRedirectEnabled
|
A
true or false value. If set to false and profile page is disabled on the
Portal, then Redeem Invitation workflow doesn't work properly and keeps
redirecting user to same page in place of home page.
|
Authentication/Registration/LoginButtonAuthenticationType
|
If
a portal only requires a single external identity provider, this allows the
Sign-In link on the primary navigation to link directly to the sign-in page
of that external identity provider
|
Authentication/Registration/OpenRegistrationEnabled
|
A
true or false value. If set to true allows any anonymous visitor to the
portal to create a new user account.
|
Profile/ShowMarketingOptionsPanel
|
A
true or false value. If set to false, it hides the marketing preferences area
in the contact profile
|
Profile page
Profile page is a
custom aspx page which displays Contact entity's "Profile Web Form"
on the profile page. If you want to change the fields on this page, you must
modify "Profile Web Form" on the contact entity. In addition of
fields on the "Profile Web Form", the profile pages show Marketing
Preferences. Marketing Preferences can be enabled or disabled by using
Profile/ShowMarketingOptionsPanel site setting.
Customising Profile Page
Profile page is a
special page which you cannot customise using Entity forms and Metadata. An
ordinary web page like a case form in portal rely on "Entity Forms".
The case of Profile page is different. The Profile page does not rely on Entity
forms, but it re-writes the request to "Profile.aspx". So, in case if
you want to change the form behavior or add validation to fields on the screen,
you will need to come with a different approach.
Scenario:
- The mobile phone on the profile should be in the format xxxx-xxx-xxx
- The profile page should be editable if the contact has NO active cases
- The profile page should be read-only if the contact has active cases
Implementation:
- Deactivate the existing Profile web page
- Create a new Entity Form called "Editable Profile Entity Form" interfacing "Profile Web Form" in Edit mode
- Create a new Entity Form called "Read-only Profile Entity Form" interfacing "Profile Web Form" in Read-only mode
- Create a new Web Template called "Profile Web Template" - We will talk about this template in details later
- Create a new Page Template named "Profile"
- Open the Profile Page template and set the following values
- Type=Web Template
- Entity Name= Web Page (adx_webpage)
- Web Template = Profile Web Template (created in the step 4)
- Create a new Web Page named "Profile".
- The profile page's partial URL must be "Profile"
- Set the parent page to "Home".
- Set the Page Template to the Profile Template (created on the step 6)
- Open the Profile Web Template and add the following liquid template:
For adding the breadcramp, add the following liquid
For adding the title to the page, add the following liquid
{% block breadcrumbs %}
{% include 'Breadcrumbs' %}
{% endblock %}
For adding the title to the page, add the following liquid
{% block title %}
{% include 'Page Header' %}
{% endblock %}
For adding side
navigation, add the following liquid
{% block aside %}
{%include "side_navigation_portal" %}
{% endblock %}
The main form will
be in the Main Block
<div class="col-sm-8 col-lg-8 left-column">
{% block main %}
{% endblock %}
</div>
</div>
Now the below code
is the magic behind meeting the requirement:
Use FetchXML to
check if there are any active cases related to the contact:
{% fetchxml my_query %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" returntotalrecordcount="true" distinct="false">
<entity name="incident">
<attribute name="name" />
<attribute name="status" />
<attribute name="createdon" />
<filter type="and">
<condition attribute="parent_contact" operator="eq" value="{{User.Id}}" />
<condition attribute="status" operator="eq" value=0 />
</filter>
</entity>
</fetch>
{% endfetchxml %}
- The FetchXML block must be enclosed in the {%fetchxml my_query%} where my_query is holding the result of the query
- If you want to check the total records returned by the query, you must use returntotalrecordcount=true otherwise you will always get -1 in count of your records
- The total count of result of the query will be accessed by my_query.results.total_record_count
The final piece of code in the page template will be the
following
{% if my_query.results.total_record_count > 0 %}
{% entityform name: 'Read only - Profile Entity
Form' %}
{% else %}
{% entityform name: 'Editable - Profile Entity Form' %}
{% endif %}
With this simple if/else statement you can control the
behavior of the profile page.
Validating Mobile phone
Since we are using Entity Forms to show profile information,
we can use Entity Form Metadata to control behavior of fields on the form. To
ensure our mobile number is always in xxxx-xxx-xxx format, do the following:
- Open Editable - Profile Entity Form
- From related records, go to "Entity Form Metadata"
- Add a new metadata record with the following properties:
- Type: Attribute
- Attribute Logical Name: Mobile Phone (mobilephone)
- Find Validation section down the form and add Validation Error Message
- Use the ^\d{4}\s\d{3}\s\d{3}$ as regular expression to ensure the mobile phone is in the xxxx-xxx-xxx format
- You can tick the "Is Field Required" to make the field required on the screen
Comments
Post a Comment