Skip to main content

Notifications

Announcements

No record found.

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

Option Set value selected "yes" means date filed should make as mandatory field in CRM Portal.

Posted on by 120

Hi Team,

I am having a Option set field(yes/No) with the values of 

Yes:101

No:102

And One more field Date field

If i am selecting yes means date field should make as a mandatory field to fill portal side.

If No means date field should make as a non mandatory field to fill portal side

like below

pastedimage1661270435920v1.png

  • Inogic Profile Picture
    Inogic 24,094 on at
    RE: Option Set value selected "yes" means date filed should make as mandatory field in CRM Portal.

    Hi Haritha,

    If you are still looking for solution, please find the below code for reference and add it into your basic form(entity form) under(Additonal settings tab) as custom javascript:

    $(document).ready(function() {

    // Add event validator

    if (typeof(Page_Validators) == 'undefined') return;

    // Create new validator

    var newValidator = document.createElement('span');

    newValidator.style.display = "none";

    newValidator.id = "new_dateofdischargeValidator";

    newValidator.controltovalidate = "new_dateofdischarge";

    newValidator.errormessage = "<a href='#new_dateofdischarge_label'>Date is a required field.</a>";

    newValidator.evaluationfunction = function() {

    if (!$('#new_previouspicuadmissionfortoday_0').is(':checked') && $('#new_previouspicuadmissionfortoday_1').is(':checked')) {

    if ($('#new_dateofdischarge').val() == "") {

    return false;

    } else {

    return true;

    }

    } else {

    return true;

    }

    };

    Page_Validators.push(newValidator);

    // Add validator element

    $("#new_previouspicuadmissionfortoday_0").change(function() {

    if (this.checked) {

    $("#new_dateofdischarge").attr('aria-required', "false");

    $('#new_dateofdischarge').parent().prev().removeClass("required");

    }

    });

    $("#new_previouspicuadmissionfortoday_1").change(function() {

    if (this.checked) {

    $("#new_dateofdischarge").attr('aria-required', "true");

    $('#new_dateofdischarge').parent().prev().addClass("required");

    }

    });

    })

    If selected value is set to “No” then date field is set to not required as shown below:

    1CRM-Portal.png

    If selected value is “Yes” date field is set to be required as shown below:

    2CRM-Portal.png

    Hope this helps.

    Thanks!

  • Suggested answer
    Haritha222 Profile Picture
    Haritha222 120 on at
    RE: Option Set value selected "yes" means date filed should make as mandatory field in CRM Portal.

    Using JQuery we can achieve this

    [quote user="Haritha222"]

    Hi Team,

    I am having a Option set field(yes/No) with the values of 

    Yes:101

    No:102

    And One more field Date field

    If i am selecting yes means date field should make as a mandatory field to fill portal side.

    If No means date field should make as a non mandatory field to fill portal side

    like below

    pastedimage1661270435920v1.png

    [/quote]

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans