web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Is there Conditional Logic on Event forms?

(0) ShareShare
ReportReport
Posted on by 69

I would like conditional logic on event registration forms, something like - if Attendee Type = Student, display 2 additional fields on the form. Is this possible?

I have the same question (0)
  • Suggested answer
    d_radulova Profile Picture
    2 User Group Leader on at

    Hi @NJD365Partner,

    I think you might need some custom JavaScript for this. And don't make the hidden fields mandatory. ;)

    Thanks,

    -DD

  • Suggested answer
    cloflyMao Profile Picture
    25,210 on at

    Hi NJD365Partner,

    You can achieve it with some javascript/typescript code.

    (Event website is built with Angular, and Angular is written in a superset of JavaScript called TypeScript.)

     In Angular, there shall be many approaches to show/hide fields based on selected option value,

    here is my solution:

    1. In custom-registration-fields.component.ts file, (folder path src\app\components\eventregistration\attendee\custom-registration-fields)

    create a string type variable to store the selected option value,

    create a function to assign selected option value to the variable.

    pastedimage1591943419636v1.png

    public selectedOption: String = "";
    
    public showField(val: String) {
        this.selectedOption = val.substring(2, val.length).replace(/\s/g, "");
    }

    Due to the original format of the selected option value will be something likes these:

    01: XXX,

    02: YYY,

    so I use substring method to extract the actual value we want, then remove any possible spaces with regex.

    2. In custom-registration-fields.component.html,(same folder with ts file)

    Jump to single choice element, (It is under <!-- Single Choice --> comment)

    bind variable assignment function to onChange event of select element, and pass the selected option value as parameter to the function. ($event.target.value)

    6355.JPG

    There are 4 types for custom registration field(simple text, boolean, single choice, multiple choice),

    in my demo, I only added two simple text type fields, so here I just added condition checking statement to simple text element.

    Add selectedOption == 'Student' condition to ngIf directive of single text element.

    5342.JPG

    Test result:

    By default there is only an optionset field:

    pastedimage1591944611609v2.png

    There are three options in optionset field.

    pastedimage1591944640592v3.png

    If I choose Teacher or Manager, nothing happens.

    pastedimage1591944699251v4.png

    pastedimage1591944724354v5.png

    If I choose Student, then other two hidden fields will show.

    pastedimage1591944763048v6.png

    Regards,

    Clofly

  • Suggested answer
    NJD365Partner Profile Picture
    69 on at

    Wow! Thank you Clofy. Would you be interested in helping us set this up for an hourly fee? Thank you for the in-depth response.  

  • cloflyMao Profile Picture
    25,210 on at

    Hi NJD365Partner,

    It will be glad if my answer could help you.

    However in forum, we could only give a solution in post.

    Please contact to developers in your team or your partners for deployment.

    You could ask any question when setting up the customization code.

    Regards,

    Clofly

    Please kindly mark as verified if you had found any anwser helped, it would be really appreciated.

  • KishoreBethi Profile Picture
    5 on at

    Hi Clofly,

     The above logic works fine if there is only one select field. If the form has multiple dropdowns and i want to hide/show the certain fields based on different dropdown values. Can you suggest the best way to solve this?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans