Tuesday, 12 May 2020

Tutorial: Customize and Extend the Dynamics 365 Event Management Marketing Portal Part 2: Work with Standard Event Fields


Hi everyone,

In my previous posts: 
we have learned how to customize, test locally, and deploy to your actual and LIVE environment.

We also learned how to declare and use variable then display it into your portal

Those links are the Dynamics Marketing Portal Customization and Extension Series.
Now, let’s continue our learning to deal with real field/attribute.

From your portal, you can see the Available Event List as shown below:



Now, it is only showing Event Name, Building Name, and Dates

What if you want to add new information, for example some fields from the form



In this example, we can use the standard available fields first, most important is you are able to get and display it.
Let’s just get the “Allow anonymous registrations” Boolean first


Go back to your code and then you add following code (span) in the home.component.html


<div *ngIf="allEvents" class="container mt-5" id="all-events">
        <div class="row">
            <div class="col-12 col-md-6 col-lg-4" attr.data-href="/event?id={{ event.readableEventId }}" *ngFor="let event of allEvents">
                <div class="card mx-auto mb-4" style="width: 18rem;">
                    <div class="card-body">
                        <h5 class="card-title">
                             <a [routerLink]="['/event']" [queryParams]="{id: event.readableEventId}" title="{{ event.eventName }}" [attr.aria-label]="getAreaLabel(event)">
                                {{ event.eventName }}</a>
                        </h5>
                        <h6 *ngIf="event.building" class="card-subtitle mb-2 text-dark">at {{ event.building.name }} </h6>
                        <span>Allow Anonymous Registration: </span><span *ngIf="event.allowAnonymousRegistrations" class="card-subtitle mb-2 text-dark">{{ event.allowAnonymousRegistrations }} </span>                        
                    </div>
                    <div class="card-footer text-dark" >
                       {{ getDateString(event) }}
                    </div>
                </div>
            </div>
        </div>
    </div>

And here is the result:

Now, you can see that the code is actually showing the value “true” but the Private Event “Allow Anonymous Registration” field value is actually NOT True, but it does not show as False, so how to show the either true or false?
You need to understand how it works in Angular.js in HTML, that is using *ngif syntax


<span>Allow Anonymous Registration: </span> 
                        <span *ngIf="event.allowAnonymousRegistrations; else showFalse" class="card-subtitle mb-2 text-dark">{{ event.allowAnonymousRegistrations }} </span>  
                        <ng-template #showFalse>   
                            <span>false</span> 
                        </ng-template>                  

Result:

Next, is to learn how to use .ts script instead of HTML. You can still use HTML method, however for complex scenario, I feel as developer, I love to do it using code behind approach.

Instead of showing “so-boolean value”, true or false, we want to show YES or NO

So, let’s add function that will handle the logic in your .ts script.
Where is it? As you are updating home HTML, then you should also update the ts that is the correspondence of home HTML, that is home.component.ts


Then do not forget to call it from your HTML
*I commented the previous code, instead I change it with simple line:

 <span> {{ getAllowAnonymousRegistrationLabel(event) }}</span>

Since it has been handle by the .ts file.


Result:

Hope it helps!

*For custom field, we can discuss in the next post


Thank you so much.
Best regards,

Aileen



Dynamics 365 Marketing Portal: Understand "Allow Anonymous Registration" field in real LIVE of Event Management Portal


Hi everyone,

Quick post here is to understand the usage of “Allow Anonymous Registration” field in the Event/Marketing Module and the impact to our Portal




Allow Anonymous Registration ==  TRUE
  • Means you DO NO need to Sign in to register the event
  • The registration form is straightaway opened for you and everyone else (unless you have another setup like maximum capacity, expired registration window, wtc)



Allow Anonymous Registration == FALSE
  • Means you NEED to Sign in to Register


Hope it helps!
Thanks


Tutorial: Customize and Extend the Dynamics 365 Event Management Marketing Portal Part 1: Understand, Add, Use, and Display Variable

Hi everyone,

In my previous posts: 



we have learned how to customize, test locally, and deploy to your actual and LIVE environment.

But, that is only simple customization, what if you want to customize more?
For example you want to add new variables/ fields, not only just customize the UI?

Let’s just add the Date field in the Main Page

Add the following code in the viewer:


Is that all?
No, you also need to make sure that myDate is a known variable:
As the home.component.html is the viewer, then the code behind is the same name ending with .ts extension


Here is the result!

Yesss now you know how to add custom variable, use it, and display it into your Main Page and you know how do do simple code to show date/time, it is just like C# OR JavaScript programming that you are familiar with. You just need to deploy it.
I suggest you start doing development and deployment locally to be more productive.

In the next post, I will share how to deal with real field.

Hope it helps!
Thanks

Tutorial: Customize and Deploy Dynamics 365 Marketing Event Management or Other Portal


Hi everyone,

I would like to share how to customize and deploy portal code to your Dynamics 365 Portal.
Before that, make sure you have read my other post regarding to what the pre-requisites are and how to code & test plus deploy locally.

This is to ensure you have done every step, including downloading sample website to customize the source code and you have done the required steps without missing anything.

Next is how do you customize it?

First, you just need to try if you are able to modify small changes and then deploy it to your Dynamics Marketing Portal (or any other portal I guess).
I am using Marketing – Event Management Portal because I am working on some requirements and I have searched in the internet, there is no detailed steps at the moment, so I tried and encountered errors and tried again until I managed to find the answer and want to share it.

Here is the portal before I customize
 

(*Actually I have customized some – the Aileen Test is the additional I added during testing 😊 , but let’s just use this as our original state*)

So, now let’s say you want to add something or change color, you can go back to your code (again, I assume you know already how to access your code – that’s why my above link is useful for starter).

YES!! You don’t need to run Visual Studio App then open the project, you can just using PowerShell

I am using very simple PowerShell:
 
It then will open Visual Studio Code

Now let’s follow the steps to customize it
Let’s see you want to modify the Main Page like what I did for Aileen Test, you need to understand where is it being located in your Portal and the Source Code.
Do you know where is it??

Here is the default Marketing – Event Management Portal



So, the first page is the All Events, I have been searching in any web files and any web/page template, code snippets in the Dynamics 365 instance but I got nothing.
I searched in the internet, I could not find it, and it is actually the way Angular works (P.S. I did not have much experience using Angular except for this one and PCF 😊) is by compiling everything and put it into main.js only.

Okay, since there is no much information, I tried to find it one by one and I tried to find “Available Events” keyword.

Have you found where it is??


Yes, it is behind the code!!

I found it in the home.component.html, which is located under src->app->components->home



However, you will not find it in the Home HTML in your Dynamics 365 instance just like old days of Portal. Not here, not there..



Not even here..






So, let’s just try and I will let you know where it is stored.

 Now, you want to change the color and add some words:



After that, you just want to deploy it!

To deploy it, you need to go to the DeployToDynamics365Instance.ps1 – it is located under Scripts folder

Then you need to change the Connection string or you can use InteractiveMode by uncomment it and comment the next return.

Remember in Powershell script # is comment not // or <!—or --

 Then after that you just need to Run/execute the script

I am using this button to run:


Wait.. and wait


then refresh your portal after you see this:



Refresh and here is what you will see (you may need to wait a while and keep hitting Ctrl+F5)



Before
After


Now you know how to customize it and deploy it LIVE to your Dynamics Portal.

But, are you wondering “Where is my customization stored actually”?

Actually, it is inside the main.es file (Web files)





Hope this helps!

Thank you and stay safe & healthy everyone!