Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Event Portal Custom Fields Creating own API

Posted on by 90

Hello All,

I am using a custom event field on the event portal, added the field in the Selected fields of Website Entity Configuration.

And i can refer it as this.event.customFields.msevtmgt_expectedoutcome in the event.component.html

I am bit confused how to refer this custom field in the event.component.ts

For example console.log(this.event.customFields.msevtmgt_expectedoutcome);

I tried to follow steps mentioned in https://pkoval.com/2019/04/07/extending-dynamics-marketing-event-management-portals/

1) Created a Web Page, Page Template and Web Template with liquid script as mentioned

2) Added ExpectedOutcome.ts class in the \src\app\models

export interface Outcome {
   expectedoutcome: string;
}

3)  getExpectedOutcome(readableEventId: string): Observable<string>; Added in the EventService.ts class

4) Implemented the same function in EventD365Service, EventRestService.

  public getExpectedOutcome(readableEventId: string): Observable<string> {
        return this.http.get(
            `${environment.apiEndpoint}${EventD365Service.eventsEndpoint}/expectedoutcome/?readableEventId=${readableEventId}`
        );
    }
}

5) Added below line in event.component.ts

this.outcome = await this.eventService.getExpectedOutcome(this.readableEventId).toPromise();

My requirement is
I want my own WebAPI to return me event ID based on custom field event language and event category.

My questions are :

Q1) What should be type of 'T' the function getExpectedOutcome(readableEventId: string): Observable<T>;??

Q2) This function should be implemented in both the event.rest.service.ts and event.d365.service.ts??

Q3) Is there any other way to create own Web API?

NOTE: I am running the Event Portal on my local host after customization is this the reason i am not getting the value of the Web API

I am bit confused. Can any one help me.

Kind Regards

Abhilash

  • Suggested answer
    KAlx Profile Picture
    KAlx on at
    RE: Event Portal Custom Fields Creating own API

    Hi Abhilash,

    Q1) What should be type of 'T' the function getExpectedOutcome(readableEventId: string): Observable<T>;??

           A1) T stands for the data type the method will return. 

          TypeScript: Handbook - Generics (typescriptlang.org)

    Q2) This function should be implemented in both the event.rest.service.ts and event.d365.service.ts??

          A2) The event website can be hosted in 2 ways : Either hosted in Portals or Self hosted. Please read the full documentation to understand how the website works :

    Self-hosted custom event website (Dynamics 365 Marketing Developer Guide) | Microsoft Docs

    Dynamics 365 Portal hosted custom event website (Dynamics 365 Marketing Developer Guide) | Microsoft Docs

    The two classes are used for separate purposes depending on how the website is configured in the environment.ts file. If it's configured as a self hosted website, it will use the event.rest.service.ts . This approach will use the Events Public API. If the website is portals hosted it will use the event.d365.service.ts. This will use Portal API. Since you are using Portals, you will need to implement the service logic in event.d365.service.ts. As the two classes extend the same interface, the method will need to be declared in the event.rest.service.ts  as well.

    Q3) Is there any other way to create own Web API?

    Implementing your own Web API is quite a challenging task and I would not recommend doing it unless you have very good understanding of how the whole system works. You would need to get familiar with website code and how the angular framework works in general, you would also need to have a good understanding on how to build your liquid template and simulate your API to work as expected. This might even require some changes in the portal structure + some plugin development. As you can see this is quite a lengthy process. My suggestion is to work with the OOB functionality and customize the OOB response ( docs.microsoft.com/.../customize-events-api-response ) , then model your custom logic around the custom responses. This will allow you to send any custom field to your website code and use them later on.

    To help better understand the angular code please visit Angular - Getting Started with Angular: Your First App . 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans