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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archive)
Suggested answer

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

(0) ShareShare
ReportReport
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

Categories:
I have the same question (0)
  • Inogic Profile Picture
    23,947 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
    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

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard > 🔒Ι Microsoft Dynamics CRM (Archived)

Featured topics

Product updates

Dynamics 365 release plans