Skip to main content

Notifications

Announcements

No record found.

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

Is there Conditional Logic on Event forms?

(0) ShareShare
ReportReport
Posted on by 67

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?

  • KishoreBethi Profile Picture
    KishoreBethi 5 on at
    RE: Is there Conditional Logic on Event forms?

    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?

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Is there Conditional Logic on Event forms?

    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.

  • Suggested answer
    NJD365Partner Profile Picture
    NJD365Partner 67 on at
    RE: Is there Conditional Logic on Event forms?

    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.  

  • Suggested answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: Is there Conditional Logic on Event forms?

    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
    d_radulova Profile Picture
    d_radulova 2 User Group Leader on at
    RE: Is there Conditional Logic on Event forms?

    Hi @NJD365Partner,

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

    Thanks,

    -DD

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans