Tuesday, 12 May 2020

Tutorial: Customize and Extend the Dynamics 365 Event Management Marketing Portal Part 3: Manipulate UI and Show/Hide Events


Hi everyone,


we have learned how to customize and modify the Portal Source Code and inject some logic inside, this enables you to extend the basic functionality into you or your customer’s unique requirements.

We have also learned about the “Allow Anonymous Registration” field and its impact in the standard Portal.


This field allows you to control whether everyone without signing in can or cannot register your event.

However, some customers may have requirements to just filter out and hide the “Private Events” instead of asking users to sign in since we already had a standard flag. With this, public users will not even able to see and aware that there are such events.

Now, let’s start our development.

Back to your code again.

We have learned how the Portal source code structure is and which part has to modify.
All available events are basically showing all upcoming event which has been published with LIVE status in your Dynamics Marketing, this never excludes anything regardless on which login you are using without further customization.

Just to share with you, the function that is being called is actuallty this function:


Then if we go deep again, we found this function (inside event.d365.service.ts) that is calling API ../published


I have checked, at least for now that I am aware of, there is no way to modify the /published API from UI.

So, you can just use old style method that is backend customization through programming by utilizing a field.

In this example and actually for your real project, you can just use “Allow Anonymous Registration” or “Event Type” or “Format” field.

Let’s code!

When we understand correctly, actually the event list is managed by a variable that is located in the home.component.html, that is “allEvents”

It means the part of the code that we need to change is only this part:


We have learned how to use ngIf previously in my previous post: 

It is all about angular.js and type script but if you are already familiar with javascript or C# or Java, and ASP.NET with MVC concept, this will not be difficult for you to learn. P.S. I mentioned before, I have no experience in Angular and typescript before too.

The key is this highlighted part:
*ngFor="let event of allEvents"

This part is to loop every event of allEvents object



Now, just change your code to:



<div *ngIf="allEvents" class="container mt-5" id="all-events">
        <div class="row">
            <div *ngFor="let event of allEvents">    
                <div *ngIf="event.allowAnonymousRegistrations" class="col-12 col-md-6 col-lg-4" attr.data-href="/event?id={{ event.readableEventId }}">    
                    <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; else showFalse" class="card-subtitle mb-2 text-dark">{{ event.allowAnonymousRegistrations }} </span>  
                            <ng-template #showFalse>   
                                <span>false</span> 
                            </ng-template>
                            -- change to-->  
                            <span> {{ getAllowAnonymousRegistrationLabel(event) }}</span>             
                        </div>
                        <div class="card-footer text-dark" >
                        {{ getDateString(event) }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

Let’s see the result!

*Before

















*After:

Now you as public user can only view 2 event which are NOT a Private event.


**Of course you can use other fields or other logic to adjust to your requirements.

In my previous post, we have learned how to modify the code and add some logic that can be done through viewer (HTML) or its typescript code.
The same case here, I have tried the same method and it works.

So, instead of manipulating the UI with adding another DIV and put in ngif in the inner DIV, I can use code to control.
I revert back the UI code to its original state and commented my changes.



Now, go to the .ts file, this is the key:



As you know that allEvents is a collection or array of list of event, so you can definitely filter out the available events by filtering allEvents based on “Allow Anonymous Registration” field.

So, I have added new line below the this.allEvents = events; and comment it first

Result before changes:



You can still see 3 events, now uncomment the filter.


private loadPublishedEvents() {
        this.isLoading = true;
        this.eventService.getPublishedEvents().subscribe(
            events => {
                this.allEvents = events;
                this.allEvents = events.filter(evt => evt.allowAnonymousRegistrations);
                this.isLoading = false;
            },
            (errorLocalizableError=> this.handleErrorResponse(error)
        );
    }

This is the result


After finished the steps, you managed to learn how to filter, show, and hide the events based on logic you implemented.

Hope this can help you to understand how to control your Portal, not only Events but other things, what to display and what to hide, and manage the messages or UI that public will see.
You can either modify the UI/viewer or the code.

Thank you!
  

27 comments:

  1. This post of yours is very good, the content you wrote inside the post is very beautiful, I am getting to learn and understand a lot from it, you keep writing similar posts even further in your life.
    call girls in gurugram
    Gurugram call girls

    Gurugram escorts
    golden opportunity

    ReplyDelete
  2. Heartily appreciate your contribution Because that is unbeatable informative content. Find dynamics 365 business central implementation

    ReplyDelete
  3. Thanks for sharing this informative content , Great work
    Leanpitch provides online training in Enterprise agile coaching during this lockdown period everyone can use it wisely.
    Enterprise agile coaching

    ReplyDelete
  4. Lead Capture app I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.

    ReplyDelete
  5. Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!THANKS!!!!!! https://clarkdlayton.wixsite.com/besteventcompany

    ReplyDelete
  6. This post is extremely radiant. I extremely like this post. It is outstanding amongst other posts that I’ve read in quite a while. Much obliged for this better than average post. I truly value it! bridal shower venues in georgetown tx

    ReplyDelete
  7. Agility is crucial for adapting to shifts in the digital marketing landscape. Digital Marketing Agency Ireland

    ReplyDelete
  8. To Learn More About The Top MT5 White Label Solution, visit MT5 White Label Solution

    ReplyDelete
  9. The production on this event was absolutely top-notch. Florida DnB Events

    ReplyDelete
  10. The integration capabilities of MS Dynamics CRM streamline operations and improve customer relationship workflows seamlessly.
    microsoft dynamics crm company
    msft dynamics crm

    ReplyDelete
  11. Great explanation! The way you broke down the steps to customize the portal is very helpful. Thank you for sharing.
    modular workstation noida
    office chair in noida

    ReplyDelete
  12. I never thought about using the “Allow Anonymous Registration” field this way.
    cafeteria-furniture noida
    metal storage system in noida

    ReplyDelete
  13. Amazing tutorial! Your detailed walkthrough of Angular code is incredibly insightful.
    Shrink Packing machine India
    Shrink wrapping machine India

    ReplyDelete
  14. Thanks for sharing! The before-and-after examples made the process much clearer.
    Box Wrapping machine delhi
    Strapping machine in delhi

    ReplyDelete
  15. Incredible post! I appreciate the emphasis on flexibility for customer requirements.
    Invest in Brands
    Dust Collector

    ReplyDelete
  16. Very informative! This will help us greatly in our upcoming Dynamics project.
    Argan Oil Manufacturer in germany
    Office Furniture manufacturer noida

    ReplyDelete
  17. Brilliant! The way you’ve detailed the “ngFor” functionality is super useful for beginners.
    mobile compactor Manufacturer
    fifo flow rack

    ReplyDelete
  18. Excellent guide! I’ve bookmarked this for future reference when working with Dynamics portals.
    heavy duty rack supplier
    Multi tier rack supplier

    ReplyDelete
  19. Fantastic post! The use of Angular concepts here is an eye-opener. Thanks for simplifying it.
    Fabric Roll Racks Manufacturer
    Warehouse mezzanine floor manufacturer

    ReplyDelete
  20. Appreciate the effort! Your step-by-step approach makes it easier to follow for newbies like me.
    slotted Angle rack manufacturer delhii
    Modular Mezzanine floor manufacturer

    ReplyDelete
  21. Thanks for the details! I was stuck on customizing the event list, and this is exactly what I needed.
    pallet rack in delhi
    Industrial Storage Rack Manufacturer

    ReplyDelete
  22. Kudos to you! You’ve made Angular and TypeScript customization less intimidating for us.
    Pallet rack hyderabad
    Heavy Duty Racking System delhi

    ReplyDelete
  23. Insightful article! The way you’ve balanced UI and backend modifications is commendable.
    Rotary Air Locks in delhi
    Dust Collector Manufacturer India

    ReplyDelete
  24. Thank you! I learned a lot about Dynamics portal customization from this.
    Dust Collector Manufacturer
    Centrifugal Blower in delhi

    ReplyDelete

My Name is..